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
tony 你好!首先感谢你提供的模板,格式内容和代码结构都很清晰明了,可读性很强,对初学者很友好,已加星🌟。
我在本地开发的时候遇到了如题所示的问题,使用 Google 登录会超时报错,但同时 GitHub 登录正常。想请教一下该如何解决。
相关代码 ` //src/app/api/auth/[...nextauth]/option.ts export const authOptions: NextAuthOptions = { // Secret for Next-auth, without this JWT encryption/decryption won't work secret: process.env.NEXTAUTH_SECRET,
// Configure one or more authentication providers providers: [ GithubProvider({ clientId: process.env.GITHUB_APP_CLIENT_ID as string, clientSecret: process.env.GITHUB_APP_CLIENT_SECRET as string, }), GoogleProvider({ clientId: process.env.GOOGLE_CLIENT_ID as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, httpOptions: { timeout: 50000, //agent: proxyAgent, }, }), ],
debug: true,
pages: { //signIn: "/auth/login", }, }; //src/app/api/auth/[...nextauth]/route.ts //这里的代码没有改过 import NextAuth from "next-auth"; import { authOptions } from "./option";
const handler = NextAuth(authOptions);
export { handler as GET, handler as POST }; //.env.local GITHUB_APP_CLIENT_ID="Ov2****" //已隐藏部分密码,下同 GITHUB_APP_CLIENT_SECRET="313****"
GOOGLE_CLIENT_ID="614****" GOOGLE_CLIENT_SECRET="GOC****"
NEXTAUTH_SECRET="OtA****" NEXTAUTH_URL="http://localhost:3000" # 开发环境`
`//.env.production GITHUB_APP_CLIENT_ID="Ov2****" //与.env.local 配置相同 GITHUB_APP_CLIENT_SECRET="313****" //与.env.local 配置相同
GOOGLE_CLIENT_ID="614****" //与.env.local 配置相同 GOOGLE_CLIENT_SECRET="GOC****" //与.env.local 配置相同
NEXTAUTH_SECRET="OtA****" //与.env.local 配置不同 NEXTAUTH_URL="https://test-running-dev.vercel.app" # 生产环境`
预期逻辑 :希望本地开发环境和线上生产环境都可以正常登录 Google。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
tony 你好!首先感谢你提供的模板,格式内容和代码结构都很清晰明了,可读性很强,对初学者很友好,已加星🌟。
我在本地开发的时候遇到了如题所示的问题,使用 Google 登录会超时报错,但同时 GitHub 登录正常。想请教一下该如何解决。
a. local 和 production 都换成同一个凭据,且在凭据中增加 http://localhost(信任源)和 http://localhost/api/auth/callback/google(回调 URI)
b. local 和 production 都换成同一个凭据,且在 a 基础上把线上域名和 localhost:3000 都加到信任源和回调 uri
c. local 和 production 都换成同一个凭据,且在 b 基础上额外增加 http://localhost(不加端口 3000),回调也加
相关代码
`
//src/app/api/auth/[...nextauth]/option.ts
export const authOptions: NextAuthOptions = {
// Secret for Next-auth, without this JWT encryption/decryption won't work
secret: process.env.NEXTAUTH_SECRET,
// Configure one or more authentication providers
providers: [
GithubProvider({
clientId: process.env.GITHUB_APP_CLIENT_ID as string,
clientSecret: process.env.GITHUB_APP_CLIENT_SECRET as string,
}),
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
httpOptions: {
timeout: 50000,
//agent: proxyAgent,
},
}),
],
debug: true,
pages: {
//src/app/api/auth/[...nextauth]/route.ts
//signIn: "/auth/login",
},
};
//这里的代码没有改过
import NextAuth from "next-auth";
import { authOptions } from "./option";
const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };
//.env.local
GITHUB_APP_CLIENT_ID="Ov2****" //已隐藏部分密码,下同
GITHUB_APP_CLIENT_SECRET="313****"
GOOGLE_CLIENT_ID="614****"
GOOGLE_CLIENT_SECRET="GOC****"
NEXTAUTH_SECRET="OtA****"
NEXTAUTH_URL="http://localhost:3000" # 开发环境`
`//.env.production
GITHUB_APP_CLIENT_ID="Ov2****" //与.env.local 配置相同
GITHUB_APP_CLIENT_SECRET="313****" //与.env.local 配置相同
GOOGLE_CLIENT_ID="614****" //与.env.local 配置相同
GOOGLE_CLIENT_SECRET="GOC****" //与.env.local 配置相同
NEXTAUTH_SECRET="OtA****" //与.env.local 配置不同
NEXTAUTH_URL="https://test-running-dev.vercel.app" # 生产环境`
预期逻辑 :希望本地开发环境和线上生产环境都可以正常登录 Google。
The text was updated successfully, but these errors were encountered: