We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I got routes are calling without authentication. Even I used protected but it's not working. Here below my snippet :
//in routes.js
import UniversalRouter from 'universal-router'; const routes = [ path: '/', protected : true, async action() { const Home = await new Promise((resolve) => { require.ensure([], (require) => { resolve(require('./Home').default); }, 'home'); }); return <Home key={'home'} />; }, ];
//When router resolve app.get('*', async (req, res, next) => { try { let css = new Set(); let statusCode = 200; const data = {title: '', description: '', style: '', script: assets.main.js, children: ''}; await UniversalRouter.resolve(routes, { path: req.path, query: req.query, context: { insertCss: (...styles) => { styles.forEach(style => css.add(style._getCss())); // eslint-disable-line no-underscore-dangle, max-len }, setTitle: value => (data.title = value), setMeta: (key, value) => (data[key] = value), }, render(component, status = 200) { css = new Set(); statusCode = status; data.children = ReactDOM.renderToString(component); data.style = [...css].join(''); return true; }, }); const html = ReactDOM.renderToStaticMarkup(<Html {...data} />); res.status(statusCode); res.send(`<!doctype html>${html}`); } catch (err) { next(err); } });
Can somebody please explain how to redirect them on login screen ?
The text was updated successfully, but these errors were encountered:
In your example, it's unclear where the render(component, status) is called from. In the current version of React Starter Kit you can find an example.
render(component, status)
Sorry, something went wrong.
No branches or pull requests
I got routes are calling without authentication. Even I used protected but it's not working. Here below my snippet :
//in routes.js
Can somebody please explain how to redirect them on login screen ?
The text was updated successfully, but these errors were encountered: