"Return 404 error code if the requested resource or route does not exist on the server."
Description:
Currently the Meteor app returns a configuration document and http code 200 if a requested document does not exist. There is a discussion about this on flow-router (which is used for apinf) GIthub project page: https://github.com/kadirahq/flow-router/issues/84
Sample code:
if(Meteor.isServer) {
WebApp.connectHandlers.use('/', function(req, res, next) {
if(isValidRoute(req.url))
return next();
res.writeHead(404);
res.end(SSR.render('404'));
});
var pathToRegexp = Meteor.npmRequire('path-to-regexp')
function isValidRoute(requestUrl) {
let splitUrl = requestUrl.split('?')[0];
for(var i = 0; i < FlowRouter._routes.length; i++)
if(pathToRegexp(FlowRouter._routes[i].path).test(splitUrl))
return true;
return false;
}
}
User Story:
"As a user of the Meteor app or as a REST API consumer, I want to receive a proper error code if the requested resource is not found."
Title:
"Return 404 error code if the requested resource or route does not exist on the server."
Description:
Currently the Meteor app returns a configuration document and http code 200 if a requested document does not exist. There is a discussion about this on flow-router (which is used for apinf) GIthub project page: https://github.com/kadirahq/flow-router/issues/84
Sample code:
User Story:
"As a user of the Meteor app or as a REST API consumer, I want to receive a proper error code if the requested resource is not found."