Redirect /challenges to /map

This commit is contained in:
Berkeley Martinez
2016-04-18 18:58:29 -07:00
parent c150ad2c34
commit caa992ecff
2 changed files with 11 additions and 3 deletions

View File

@ -1,6 +1,12 @@
import Challenges from './components/Challenges.jsx';
export default {
path: 'challenges',
component: Challenges
path: 'challenges(/:dashedName)',
component: Challenges,
onEnter(nextState, replace) {
// redirect /challenges to /map
if (nextState.location.pathname === '/challenges') {
replace('/map');
}
}
};

View File

@ -15,6 +15,7 @@ const routes = [
'/videos',
'/videos/*',
'/challenges',
'/challenges/*',
'/map'
];
@ -45,7 +46,8 @@ export default function reactSubRouter(app) {
// if react-router does not find a route send down the chain
.filter(({ redirect, props }) => {
if (!props && redirect) {
res.redirect(redirect.pathname + redirect.search);
log('react router found a redirect');
return res.redirect(redirect.pathname + redirect.search);
}
if (!props) {
log(`react tried to find ${req.path} but got 404`);