Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was 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

@martijnhiemstra

Description

@martijnhiemstra

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions