Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set proxy in Webpack production config Angular 2+

As I can see, there is proxy in webpack.dev.config. How do I set proxy in webpack.prod.config ? I want to call another api domain url other than self domain url.

like image 837
Jeeten Parmar Avatar asked May 24 '17 05:05

Jeeten Parmar


1 Answers

I going to try to provide somewhat of an answer.

As Julia points out. You should not be using the webpack dev server in your production environment as it is not meant for that, so the question should not be how to configure a production proxy config with it. That being said, if you really want to you can start a webpack server with custom proxy config like so:

ng serve --proxy-conf proxy.conf.json

What you should be doing is to use webpack, through the angular/cli to build a production build with and then move those files to be served by a static file server of your choosing. Build a production bundle like so:

ng build --prod

All above taken from your link https://jhipster.github.io/using-angular/

Since you are using JHipster there are already guides and tooling on how to take your code into production. Continue your reading here: https://jhipster.github.io/production/

I hope this points you in the right direction

like image 101
Hampus Avatar answered Oct 10 '22 02:10

Hampus