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'; import Challenges from './components/Challenges.jsx';
export default { export default {
path: 'challenges', path: 'challenges(/:dashedName)',
component: Challenges 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',
'/videos/*', '/videos/*',
'/challenges', '/challenges',
'/challenges/*',
'/map' '/map'
]; ];
@ -45,7 +46,8 @@ export default function reactSubRouter(app) {
// if react-router does not find a route send down the chain // if react-router does not find a route send down the chain
.filter(({ redirect, props }) => { .filter(({ redirect, props }) => {
if (!props && redirect) { if (!props && redirect) {
res.redirect(redirect.pathname + redirect.search); log('react router found a redirect');
return res.redirect(redirect.pathname + redirect.search);
} }
if (!props) { if (!props) {
log(`react tried to find ${req.path} but got 404`); log(`react tried to find ${req.path} but got 404`);