👌 update server.routes.js
This commit is contained in:
parent
d42f10e114
commit
862fe1a3ba
4 changed files with 6 additions and 52 deletions
|
@ -35,7 +35,7 @@ class App extends React.Component {
|
||||||
return (
|
return (
|
||||||
<div className="app">
|
<div className="app">
|
||||||
{/* FIXME: remove false */}
|
{/* FIXME: remove false */}
|
||||||
{this.state.isMounted && !window.devToolsExtension && getConfig('NODE_ENV') === 'development' && <DevTools />}
|
{false && this.state.isMounted && !window.devToolsExtension && getConfig('NODE_ENV') === 'development' && <DevTools />}
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -27,7 +27,7 @@ const checkAuth = (store) => {
|
||||||
// TODO: This short-circuit seems unnecessary - using the mobile <Switch /> navigator (future) should prevent this from being called
|
// TODO: This short-circuit seems unnecessary - using the mobile <Switch /> navigator (future) should prevent this from being called
|
||||||
const onRouteChange = (store) => {
|
const onRouteChange = (store) => {
|
||||||
const path = window.location.pathname;
|
const path = window.location.pathname;
|
||||||
if (path.includes('/mobile')) return;
|
if (path.includes('/mobile/preview')) return;
|
||||||
|
|
||||||
store.dispatch(stopSketch());
|
store.dispatch(stopSketch());
|
||||||
};
|
};
|
||||||
|
|
|
@ -145,54 +145,4 @@ router.get('/:username/collections', (req, res) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Mobile Routes
|
|
||||||
if (process.env.MOBILE_ENABLED) {
|
|
||||||
router.get('/mobile', (req, res) => res.send(renderIndex()));
|
|
||||||
|
|
||||||
router.get('/mobile/preview', (req, res) => res.send(renderIndex()));
|
|
||||||
|
|
||||||
router.get('/mobile/preferences', (req, res) => res.send(renderIndex()));
|
|
||||||
|
|
||||||
router.get('/mobile/:username/sketches', (req, res) => {
|
|
||||||
userExists(req.params.username, fallback404(res));
|
|
||||||
});
|
|
||||||
|
|
||||||
router.get('/mobile/:username/sketches/:project_id', (req, res) => {
|
|
||||||
projectForUserExists(req.params.username, req.params.project_id, fallback404(res));
|
|
||||||
});
|
|
||||||
|
|
||||||
router.get('/mobile/:username/assets', (req, res) => {
|
|
||||||
userExists(req.params.username, (exists) => {
|
|
||||||
const isLoggedInUser = req.user && req.user.username === req.params.username;
|
|
||||||
const canAccess = exists && isLoggedInUser;
|
|
||||||
return canAccess ?
|
|
||||||
res.send(renderIndex()) :
|
|
||||||
get404Sketch(html => res.send(html));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
router.get('/mobile/:username/collections/create', (req, res) => {
|
|
||||||
userExists(req.params.username, (exists) => {
|
|
||||||
const isLoggedInUser = req.user && req.user.username === req.params.username;
|
|
||||||
const canAccess = exists && isLoggedInUser;
|
|
||||||
return canAccess ?
|
|
||||||
res.send(renderIndex()) :
|
|
||||||
get404Sketch(html => res.send(html));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
router.get('/mobile/:username/collections', (req, res) => {
|
|
||||||
userExists(req.params.username, fallback404(res));
|
|
||||||
});
|
|
||||||
|
|
||||||
router.get('/mobile/:username/collections/create', (req, res) => {
|
|
||||||
userExists(req.params.username, fallback404(res));
|
|
||||||
});
|
|
||||||
|
|
||||||
router.get('/mobile/:username/collections/:id', (req, res) => {
|
|
||||||
collectionForUserExists(req.params.username, req.params.id, fallback404(res));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|
|
@ -132,6 +132,10 @@ app.get(
|
||||||
// isomorphic rendering
|
// isomorphic rendering
|
||||||
app.use('/', serverRoutes);
|
app.use('/', serverRoutes);
|
||||||
|
|
||||||
|
if (process.env.MOBILE_ENABLED) {
|
||||||
|
app.use('/mobile', serverRoutes);
|
||||||
|
}
|
||||||
|
|
||||||
app.use(assetRoutes);
|
app.use(assetRoutes);
|
||||||
|
|
||||||
app.use('/', embedRoutes);
|
app.use('/', embedRoutes);
|
||||||
|
|
Loading…
Reference in a new issue