angular / router

The Angular 1 Component Router
MIT License
665 stars 135 forks source link

Angular routing uses window.location url for routing and not the request url #448

Open martijnhiemstra opened 3 years ago

martijnhiemstra commented 3 years ago

I am running an angular 9 application behind nginx which is setup as a reverse proxy. When a request is forwarded to the angular application I use a proxy_pass. This passes the request on to the angular application. I have configured the reverse proxy to forward any request to /public so in other words if I do a request to http://localhost (Nginx) it sends the request to http://locahost:4200/public (Angular).

I log the url in my angular application using the following code:

router.events.forEach((event) => {
      console.log('Event', event['url']);
});

According to angular the route url is /. It should be /public. I am guessing that angular is using window.location (http://localhost) instead of the url in the request (http://localhost:4200/public).

Is this the case and if so how can this be changed because this means that Angular is useless behind a proxy where I want to forward to a different url?