Port and Proxy Config on ng-build

2019-04-07 12:56发布

问题:

I have a frontend running for example on int.myapp.com and it's backend on int.backend.myapp.com. I thought I can do the proxing with the proxy.config.json like this:

 "/api": {
    "target": "https://int.backend.myapp.com",
    "secure": true,
    "changeOrigin": true
  }

And in my package.json file

"start": "ng serve --proxy-config proxy.conf.json"

Everything works on my dev environment.

But when I build for production :

ng buil --prod

and deploy on firebase

firebase deploy

The web application is not able to communicate with the API

How can I do to fix it ?

回答1:

"build": "ng build --prod --proxy-config proxy.conf.json"