Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

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

Open
martijnhiemstra opened this issue Sep 27, 2020 · 0 comments

Comments

@martijnhiemstra
Copy link

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant