angular-cli: Proxy not working when running ng serve
OS?
Mac OSX (Sierra)
Versions.
@angular/cli: 1.0.0-beta.31 node --version v6.9.1
Repro steps.
Need to run a proxy so I added --proxy-config proxy.conf.json
in package.json
This works if I run npm start
but then I cant access the site from my mobile on the same network.
If I run ng serve
then I can use my mobile to test the site but the proxy stopps working… ?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 2
- Comments: 24 (4 by maintainers)
Did you try
?
@kultigin trying add the below to avoid ECONNRESET error { “/emport-api/*”: { “target”: “http://localhost:8080”, “secure”: false, “logLevel”: “debug”, “changeOrigin”: true, “headers”: { “Connection”: “keep-alive” } } }
Here is my working code:
We don’t support having the
proxy-conf
setting in the CLI json currently, only port/host/ssl/sslKey/sslCert. That is why it doesn’t work when you put it there.I’ll accept it as a feature request if someone wants to take it on. Otherwise this is a consideration for 2.0 (having everything customizable in the config file).
@mackelito I added similar command line(
ng serve --host 0.0.0.0 --port 4300 --proxy-config proxy.conf.json
) in package.json, and follow the Proxy to backend wiki page to create a proxy.conf.json in the same folder with package.json, but it still does not work.I am using Windows 10, I am not sure if this is a system specific problem. When I used
ng eject
to export webpack.config.json and configure the proxy in thedevServer
section, it still get the same errors in cmd console.