app sends 404 code for /fallback and failing canonical #831
1 changed files with 12 additions and 3 deletions
|
@ -50,8 +50,11 @@ export default (req, res) => {
|
|||
saga = false,
|
||||
} = httpContext.get('routeData');
|
||||
|
||||
const runSaga = (action !== false && saga !== false);
|
||||
if (action === 'fallback') {
|
||||
res.status(404);
|
||||
}
|
||||
|
||||
const runSaga = (action !== false && saga !== false);
|
||||
const renderPage = (store) => {
|
||||
|
||||
// Workaround, remove when a solution for async httpContext exists
|
||||
|
@ -115,10 +118,16 @@ export default (req, res) => {
|
|||
.then(() => {
|
||||
// redirect if request does not use canonical url
|
||||
const canonicalUrl = getCanonicalUrlFromShow(store.getState().show);
|
||||
|
||||
if (!canonicalUrl) {
|
||||
res.status(404);
|
||||
}
|
||||
|
||||
if (canonicalUrl && canonicalUrl !== req.originalUrl) {
|
||||
console.log(`redirecting ${req.originalUrl} to ${canonicalUrl}`);
|
||||
res.redirect(canonicalUrl);
|
||||
}
|
||||
|
||||
return renderPage(store)
|
||||
});
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue