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
Based on this tutorial, you need to add NextAuth to a Next.js app via the middlware.ts file.
middlware.ts
They recommend setting up the middleware.ts like this:
import NextAuth from 'next-auth'; import { authConfig } from './auth.config'; export default NextAuth(authConfig).auth; export const config = { // https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher matcher: ['/((?!api|_next/static|_next/image|.*\\.png$).*)'], };
This will not work with the multi-tenant middleware since it already has an export default.
export default
export default async function middleware(req: NextRequest) { const url = req.nextUrl; // Get hostname of request (e.g. demo.vercel.pub, demo.localhost:3000) let hostname = req.headers .get("host")! .replace(".localhost:3000", `.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}`); // special case for Vercel preview deployment URLs if ( hostname.includes("---") && hostname.endsWith(`.${process.env.NEXT_PUBLIC_VERCEL_DEPLOYMENT_SUFFIX}`) ) { hostname = `${hostname.split("---")[0]}.${ process.env.NEXT_PUBLIC_ROOT_DOMAIN }`; } ...
What is the recommended pattern here for using NextAuth in middleware while also having the custom middleware for the subdomains?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Based on this tutorial, you need to add NextAuth to a Next.js app via the
middlware.ts
file.They recommend setting up the middleware.ts like this:
This will not work with the multi-tenant middleware since it already has an
export default
.What is the recommended pattern here for using NextAuth in middleware while also having the custom middleware for the subdomains?
The text was updated successfully, but these errors were encountered: