How to use AngularJS routes with Express (Node.js) when a new page is requested?

with express 4, you probably want to catch all requests and redirect to angularjs index.html page.
app.use(app.router); doesn’t exist anymore and res.sendfile is deprecated, use res.sendFilewith an uppercase F.

app.post('/projects/', projectController.createProject);
app.get('/projects/:id', projectController.getProject);
app.get('*', function (req, res) {
    res.sendFile('/public/index.html');
});

put all your API routes before the route for every path app.get('*', function (req, res){...})

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)