I'm refactoring my Angular4+sails app so that both the views and the backend are available on localhost:1337. I've specified the routes in config/routes.js
module.exports.routes = {
'/': {
view: 'homepage'
},
'/register':{
view: 'homepage'
},
'POST /user': 'UserController.create',
'POST /user/login': 'UserController.login',
/*further code*/
};
and I have the UserController
file with login
method declared as follows:
import { Model } from 'Sails';
declare var sails: any;
module.exports = {
login: function (req, res) {
console.log("In controller");
/*further code*/
},
/*further code*/
};
all code is available here: https://github.com/adzina/web-app-1337
I access the homepage view at localhost:1337
.Login button declared in assets/app/components/LoginComponent/
performs a POST request to localhost:1337/user/login
and the response I get is: Response with status: 404 Not Found for URL: http://localhost:1337/user/login
. Any ideas what could be causing this?