nextjs + auth / 该网站无法提供安全连接

mxc*_*cdh 3 auth0 next.js

我的项目中存在安全连接问题。下面是我的设置和代码: 在此输入图像描述 在此输入图像描述

怎么了?

ps 我基于本教程的代码: https://thetechhulk.com/auth0-and-next-js-authentication-complete-guide

Pir*_*ran 15

即使您定义了 envvar,NEXTAUTH_URL="http://localhost:3000"它仍然可以重定向到https(安全版本而不是不安全版本)。

如果您运行以保持环境变量最新,则 envvar "; 可能会VERCEL="1默认发生这种情况。vercel env pull .env

为了解决这个问题,在 Vercel 中将仅用于开发的 VERCEL 环境变量设置为空白。然后下次您停车时.env您应该会看到:

VERCEL=""
Run Code Online (Sandbox Code Playgroud)

触发此操作的 next-auth 代码可以在此处查看:https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/utils/detect-origin.ts

  if (process.env.VERCEL ?? process.env.AUTH_TRUST_HOST)
    return `${protocol === "http" ? "http" : "https"}://${forwardedHost}`
Run Code Online (Sandbox Code Playgroud)


And*_*rio 9

我有一个类似的问题,问题是我NEXTAUTH_URL指的是https://localhost:3000而不是http://localhost:3000