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
In order to protect routes from unauthorized users, protected pages have this code snippet:
export const getServerSideProps = async (ctx) => { try { const admin = getFirebaseAdmin(); const cookies = parseCookies(ctx); await admin.auth().verifyIdToken(cookies.__session); return { props: {}, }; } catch (err) { // either the `__session` cookie didn't exist // or token verification failed // either way: redirect to the login page return { redirect: { permanent: false, destination: "/login", }, props: {}, }; } };
This is duplicated on every page that is protected (almost all pages...)
Next.js 12 introduces middleware which should be able to replace this duplicate code and move it to its own _middleware.js file.
Note: Relevant YouTube snippet that inspired this issue.
The following routes should be protected:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
In order to protect routes from unauthorized users, protected pages have this code snippet:
This is duplicated on every page that is protected (almost all pages...)
Next.js 12 introduces middleware which should be able to replace this duplicate code and move it to its own _middleware.js file.
Note: Relevant YouTube snippet that inspired this issue.
The following routes should be protected:
The text was updated successfully, but these errors were encountered: