I want to remove my local server prefix from my REST API URLs (example, http://localhost:8080) when building for production (ng build --prod
).
I get that i
One possible way to achieve that is, to define different base URLs based on isDevMode()
in your code. For example,
import { isDevMode } from '@angular/core';
// ...
let baseUrl: string;
if (isDevMode()) {
baseUrl = "http://localhost:8080/";
} else {
baseUrl = "http://api.myprodserver.com/";
}
// ...
Edit: This is meant to be for illustration. You'll likely want to use some type of (env-dependent) "config" in real code.