I am currently using proxy.conf.json to configure API url for development. I believe it only works on the local server. How can I configure the API url when deploying it on UAT and Production server? I would like to change the API url on the server without re-building the entire application.
proxy.conf.json:
{
"/api": {
"target": "http://api_server:88",
"secure": false,
"pathRewrite": {
"^/api": ""
},
"changeOrigin": true
}
}
api.service.ts:
get<T>(params: any = {}) : Observable<T> {
return this.http.get<T>("/api/data", {params: params});
}
This way has been working great for us:
custom-http.service.ts <- You can name this specific to your company / app name
You can call getCurrentEnvironment() from any where in your app to know which environment you are on.