webpack-dev-server and express on the same port? webpack-dev-server and express on the same port? express express

webpack-dev-server and express on the same port?


This is what worked for me:https://medium.com/@spencerfeng/setup-a-proxy-for-api-calls-for-your-angular-cli-app-6566c02a8

I feel like most people haven't ejected their webpack config... if you don't know what that means, then you've probably not ejected your webpack config so look under the option for "not been ejected" option.

I will note that if you're using ng serve instead of npm start you will either need to make the switch to npm start or type out that full command ng serve --proxy-config proxy.conf.json in order for this to work.

Additionally in your proxy.conf.json:

  • sample only shows '/api'
  • but if you've any other endpoints that don't start with /api, you will need to add them as well. Just in case you didn't realize that the '/api' was a path recognition string and not just a "setting".

example proxy.conf.json:

{     "/api": {        "target": "http://localhost:3001",       "secure": false     },     "/oauth": {       "target": "http://localhost:3001",       "secure": false     },     "/foo": {       "target": "http://localhost:3002",       "secure": false     }}