Skip to content

App will crash on Hard Reload #1

@ahsankhan1911

Description

@ahsankhan1911

Put /* in app.get

When using react client-side routing and serving production build from nodejs. The server crashes on any client side route because we are not mapping anything to that route from server like /room0 does not have any definition in server.js because we only defined / route which send index.html right now.

The best solution to this issue is to put /* rather than putting only /. It will send index.html in all requested routes which will look something like this:

app.get("/*", function(request, response){ response.sendFile(path.resolve(__dirname, "../client-web/build", "index.html")); });

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