Skip to content

Fix Angular + express.js routing to support page reload or navigating directly to a path #9

@cold-sats

Description

@cold-sats

In app.js (the express server) these 2 lines run the Angular App:

app.use(express.static(__dirname + '/dist/tao-web'));
app.get('/', (req, res) => res.sendFile(path.join(__dirname)));

If you navigate directly to http://localhost:3000 and go from there the app will work fine. You will see the paths in the browser change as you navigate. But if you refresh the page at any point or navigate directly to a path like http://localhost:3000/dashboard the app will not work.

I assume this issue happens because there is no reference to these paths in the express.js server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions