nextjs + auth / 此站点无法提供安全连接

问题描述 投票:0回答:3

我的项目中存在安全连接问题。 下面是我的设置和代码:

怎么了?

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

next.js auth0
3个回答
6
投票

我有一个类似的问题,问题是我的

NEXTAUTH_URL
指向
https://localhost:3000
而不是
http://localhost:3000


0
投票

error image - chrome

url 错误:“localhost:3000/api/auth/callbackerror=MUST+match+the+registered+callback+URL+for+this+application

检查你的 Github OAuth 授权回调 URL

Github Authorization Callback URL

检查您的“.env.local” NEXTAUTH_URL

这解决了我的问题。


0
投票

即使您定义了 envvar

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

可能是 envvar

VERCEL="1
";如果您运行
vercel env pull .env
以保持您的 envvars 最新,默认情况下会发生这种情况。

为了解决这个问题,在 Vercel 中将 Development 的 VERCEL 环境变量设置为空白。然后下次你进入

.env
你应该看到:

VERCEL=""

可以在此处看到触发此操作的下一个身份验证代码: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}`
© www.soinside.com 2019 - 2024. All rights reserved.