app sends 404 code for /fallback and failing canonical
This commit is contained in:
parent
8f9d80acbe
commit
cbb94d5e55
1 changed files with 8 additions and 3 deletions
|
@ -49,9 +49,11 @@ export default (req, res) => {
|
||||||
action = false,
|
action = false,
|
||||||
saga = false,
|
saga = false,
|
||||||
} = httpContext.get('routeData');
|
} = httpContext.get('routeData');
|
||||||
|
if (action === 'fallback') {
|
||||||
|
res.status(404);
|
||||||
|
}
|
||||||
|
|
||||||
const runSaga = (action !== false && saga !== false);
|
const runSaga = (action !== false && saga !== false);
|
||||||
|
|
||||||
const renderPage = (store) => {
|
const renderPage = (store) => {
|
||||||
|
|
||||||
// Workaround, remove when a solution for async httpContext exists
|
// Workaround, remove when a solution for async httpContext exists
|
||||||
|
@ -63,10 +65,10 @@ export default (req, res) => {
|
||||||
} else {
|
} else {
|
||||||
const channelKeys = Object.keys(showState.channelList);
|
const channelKeys = Object.keys(showState.channelList);
|
||||||
|
|
||||||
if(channelKeys.length !== 0) {
|
if (channelKeys.length !== 0) {
|
||||||
res.claimId = showState.channelList[channelKeys[0]].longId;
|
res.claimId = showState.channelList[channelKeys[0]].longId;
|
||||||
res.isChannel = true;
|
res.isChannel = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// render component to a string
|
// render component to a string
|
||||||
|
@ -115,6 +117,9 @@ 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) {
|
||||||
|
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);
|
||||||
|
|
Loading…
Reference in a new issue