Return text/plain if html isn't explicitly specified in Accept header

This commit is contained in:
Ceda EI 2020-10-23 15:10:05 +05:30
parent 24ed412f50
commit e2293900de
1 changed files with 7 additions and 3 deletions

View File

@ -141,9 +141,13 @@ app.use(connect_st({
// Then we can loop back - and everything else should be a token,
// so route it back to /
app.use(route(function(router) {
router.get('/:id', function(request, _response, next) {
request.sturl = '/';
next();
router.get('/:id', function(request, response, next) {
if (request.headers.accept.includes('html')) {
request.sturl = '/';
next();
} else {
return raw(request, response);
}
});
}));