mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Allow middleware to set http status code
This commit allows middleware to set the status code of the http response. This will allow a server-side router to return, for example, a '404 Not Found' response. This has SEO benefits because currently search engines may index example.org/page-that-doesn't-exist because Meteor returns a 200 OK code and the normal boilerplate response body. With a proper 404 status we can still return the boilerplate to render a client side 404 template but search engines won't index the page. Instead of a hardcoded 200 response, we call res.writeHead with res.statusCode, and fallback to the default 200 code if it has not been set.
This commit is contained in:
@@ -708,7 +708,8 @@ var runWebAppServer = function () {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
res.writeHead(200, headers);
|
||||
var statusCode = res.statusCode ? res.statusCode : 200;
|
||||
res.writeHead(statusCode, headers);
|
||||
res.write(boilerplate);
|
||||
res.end();
|
||||
return undefined;
|
||||
|
||||
Reference in New Issue
Block a user