Webpack Dev Server代理不会重定向到api后端

50l*_*l3r 1 javascript apache angularjs webpack webpack-dev-server

我尝试将我的“ http:// localhost:3000 / api / ”路径重定向在apache服务器中运行的“ http://example.com/api/ ”。

这是我的devServer配置:

devServer: {
    publicPath: '/build/',
    port: 3000,
    proxy: {
        '/api': {
            target: 'http://gestios.loc/api'
        }
    },
    historyApiFallback: true
}
Run Code Online (Sandbox Code Playgroud)

当我尝试访问http:// localhost:3000 / api / calltek / apps?permalink = empresas时,收到404错误。

Request URL:http://localhost:3000/api/calltek/apps?permalink=empresas
Request Method:GET
Status Code:404 Not Found
Remote Address:127.0.0.1:3000
Referrer Policy:no-referrer-when-downgrade

HTTP/1.1 404 Not Found
X-Powered-By: Express
date: Fri, 05 May 2017 18:13:42 GMT
server: Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.28
vary: accept-language,accept-charset
accept-ranges: bytes
connection: close
transfer-encoding: chunked
content-type: text/html
content-language: es
Run Code Online (Sandbox Code Playgroud)

小智 7

尝试添加

devServer: {
    publicPath: '/build/',
    port: 3000,
    proxy: {
        '/api': {
            target: 'http://gestios.loc/api'
            secure: false,
            changeOrigin: true
        }
    },
    historyApiFallback: true
}
Run Code Online (Sandbox Code Playgroud)

希望对您有所帮助