Reputation: 3414
I have nodejs angular app. Nodejs is running server. I have a ui router setup with html5mode on when i go to http://localhost:3000/superadmin node is giving 404, but when i got to http://localhost:3000/#/superadmin it redirects to http://localhost:3000/superadmin and page shows fine.
Upvotes: 0
Views: 341
Reputation: 2850
You need to tell express to redirect all requests that come to the server to your index.html
Example in your server.js file:
var express = require('express');
var app = express();
app.all('/*', function(req, res) {
res.sendfile('index.html'); // or the name of your angular app html file
});
app.listen(3000);
You need to make sure that you put app.all() below all other routes that you have defined in your express app.
Upvotes: 3