Created
October 2, 2023 18:31
-
-
Save mauriciord/6daa19349b07dd703b25bfee75f8cc1f to your computer and use it in GitHub Desktop.
Next Auth ignoring Next Auth env on proxy domains
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default async function auth(req: NextApiRequest, res: NextApiResponse) { | |
if (process.env.VERCEL) { | |
// prefer NEXTAUTH_URL, fallback to x-forwarded-host | |
req.headers['x-forwarded-host'] = | |
process.env.NEXTAUTH_URL ?? req.headers['x-forwarded-host'] | |
} | |
return await NextAuth(req, res, authOptions()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment