changing url dynamically in angular 4 depending upon the environments

531 Views Asked by At

right now to change the url for angular 4 application i am using ng build--(name of the flag) for example if it is production i use ng build --prod

what i want to achieve is for example- for local host if the URL is -https://local.com/application/overview

for staging it is - for my local host if the URL is -https://stage.com/application/overview

for production the url is it is - for my local host if the URL is -https://prod.com/application/overview.

i want to to change the hostname dynamically with me changing the url again and again. if the code is deployed to stage it should take the stage url and vice versa.

how it can be achieved? any suggestion will be appreciated.

1

There are 1 best solutions below

4
On

If your context root after first / is same in every environment then you don't need to provide a base href just use ./