5

I understand SERVER_API_URL is defined in webpack-common.js which empty by default. But in production, I will need different URL for the api, I did following addition in "plugins" array in webpack-prod.js , but do not see any effect. I believe it has to be related to webpack-merge and now it works with DefinePlugin. I tried to read documentation of webpack-merge, but looks like a lot of reading is needed.

        new webpack.DefinePlugin({
        'process.env': {
            // The root URL for API calls, ending with a '/' - for example: `"http://www.jhipster.tech:8081/myservice/"`.
            // If this URL is left empty (""), then it will be relative to the current context.
            // If you use an API server, in `prod` mode, you will need to enable CORS
            // (see the `jhipster.cors` common JHipster property in the `application-*.yml` configurations)
            SERVER_API_URL: '"http://172.26.0.150:9000/"'
        }
    })

The url is still getting picked up from webpack-common.js and has not been overriden by this setting.

1 Answers1

4

Found a solution in this stackoverflow question: How to set the REST api address in Angular according to build?

The suggestion of user2831852 works fine:

SERVER_API_URL: options.env === 'development' ? developmentHost : productionHost

Marnix
  • 59
  • 6