app sends 404 code for /fallback and failing canonical #831
1 changed files with 4 additions and 0 deletions
|
@ -49,6 +49,7 @@ export default (req, res) => {
|
||||||
action = false,
|
action = false,
|
||||||
saga = false,
|
saga = false,
|
||||||
} = httpContext.get('routeData');
|
} = httpContext.get('routeData');
|
||||||
|
|
||||||
if (action === 'fallback') {
|
if (action === 'fallback') {
|
||||||
res.status(404);
|
res.status(404);
|
||||||
}
|
}
|
||||||
|
@ -117,13 +118,16 @@ export default (req, res) => {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// redirect if request does not use canonical url
|
// redirect if request does not use canonical url
|
||||||
const canonicalUrl = getCanonicalUrlFromShow(store.getState().show);
|
const canonicalUrl = getCanonicalUrlFromShow(store.getState().show);
|
||||||
|
|
||||||
if (!canonicalUrl) {
|
if (!canonicalUrl) {
|
||||||
res.status(404);
|
res.status(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canonicalUrl && canonicalUrl !== req.originalUrl) {
|
if (canonicalUrl && canonicalUrl !== req.originalUrl) {
|
||||||
console.log(`redirecting ${req.originalUrl} to ${canonicalUrl}`);
|
console.log(`redirecting ${req.originalUrl} to ${canonicalUrl}`);
|
||||||
res.redirect(canonicalUrl);
|
res.redirect(canonicalUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return renderPage(store)
|
return renderPage(store)
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue