0

I can go to the site index www.mysite.com and from there use the app navigation to go to www.mysite.com/login but I can't go directly to www.mysite.com/login as it gives a 404 message.

However this is working in localhost, where I can go straight to https://localhost:3000/login and it will load up the app with the login page route.

How can I get this to work on my Nginx server as-well?

Michael
  • 365
  • 4
  • 15
  • You need to redirect all requests to index.html. Refer to [this](https://stackoverflow.com/questions/35038155/how-to-redirect-all-angular-request-to-index-html-in-nginx) for server configuration or you could redirect using server side like node or whatever server side you are using. – tarzen chugh Sep 25 '19 at 05:21
  • Thanks, add this as an answer and I will mark it as answer. – Michael Sep 25 '19 at 05:31

2 Answers2

1

Try this in your server.js file

app.use("/users", require("./routes/users")); app.use("/groups", require("./routes/groups")); app.use(express.static(__dirname + "/client/build")); app.get("/*", (req, res) => { res.sendFile(path.join(__dirname, "client", "build", "index.html")); });
Dixit Savaliya
  • 413
  • 3
  • 7
1

You need to redirect all requests to index.html.

Refer to this for server configuration or you could redirect using server side like node or whatever server side you are using.

tarzen chugh
  • 10,561
  • 4
  • 20
  • 30