0

I have to call a login link in window.open(), where I`ll be giving my return URL as query string parameter which it returns back to that URL. Return URL I have created a separate component for it, a temporary one which show "Please wait". The URL for the component is

url = location.origin+ "/milesConfirm"

The problem is when I do deployment(normal and prod), it is not coming back to that component. Is there any way to do this with common base url for all environment. Please help..

manoj
  • 1

1 Answers1

0

You can add setting.json file in assets folder, after ng build go to setting.json change back end url.

export class SettingService  {

  constructor(private http: HttpClient) {

  }

  public getJSON(file): Observable<any> {
      return this.http.get("./assets/configs/" + file + ".json");
  }
  public getSetting(){
      // use setting here
  }
}

In app folder, i add folder configs/setting.json

Content in setting.json

{
    "baseUrl": "http://localhost:52555"
}

In app module add APP_INITIALIZER

{
      provide: APP_INITIALIZER,
      useFactory: (setting: SettingService) => function() {return setting.getSetting()},
      deps: [SettingService],
      multi: true
    }

Refer this link Angular: Is it possible to read a json file after building

Hien Nguyen
  • 24,551
  • 7
  • 52
  • 62
  • But we can`t redirect to sub component in prod environment, Like upto home page we can search, but other component it gives error – manoj Mar 25 '19 at 08:48