lobehub / lobe-chat

🤯 Lobe Chat - an open-source, modern-design AI chat framework. Supports Multi AI Providers( OpenAI / Claude 3 / Gemini / Ollama / Azure / DeepSeek), Knowledge Base (file upload / knowledge management / RAG ), Multi-Modals (Vision/TTS) and plugin system. One-click FREE deployment of your private ChatGPT/ Claude application.
https://chat-preview.lobehub.com
Other
40.81k stars 9.29k forks source link

[Bug] Cannot parse action at /api/auth/session #3907

Open yincangshiwei opened 1 week ago

yincangshiwei commented 1 week ago

📦 部署环境

Docker

📌 软件版本

1.16.1

💻 系统环境

Other Linux

🌐 浏览器

Chrome

🐛 问题描述

我使用的是logto,配置好所有环境后,就剩登录/注册那里有问题了,点击进去就提示下面错误: [auth][error] UnknownAction: Cannot parse action at /api/auth/session .Read more at https://errors.authjs.dev#unknownaction at /app/.next/server/chunks/35411.js:1:36999 at tx (/app/.next/server/chunks/35411.js:1:37314) at im (/app/.next/server/chunks/35411.js:357:46362) at t (/app/.next/server/chunks/35411.js:357:56511) at /app/nodemodules/.pnpm/next@14.2.9@babel+core@7.23.6_supports-color@8.1.1@opentelemetry+api@1.9.0_react-dom@18.3._5qe6vzi7lz36zngmhhqssoddee/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:36938 at /app/nodemodules/.pnpm/next@14.2.9@babel+core@7.23.6_supports-color@8.1.1@opentelemetry+api@1.9.0_react-dom@18.3._5qe6vzi7lz36zngmhhqssoddee/node_modules/next/dist/server/lib/trace/tracer.js:140:36 at NoopContextManager.with (/app/node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js:25:19) at ContextAPI.with (/app/node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/src/api/context.js:60:46) at NoopTracer.startActiveSpan (/app/node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js:65:31) at ProxyTracer.startActiveSpan (/app/node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.js:36:24) image logto配置: image lobe服务环境配置:

image

📷 复现步骤

No response

🚦 期望结果

No response

📝 补充信息

No response

lobehubbot commented 1 week ago

👀 @yincangshiwei

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. Please make sure you have given us as much context as possible.\ 非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

lobehubbot commented 1 week ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


📦 Deployment environment

Docker

📌 Software version

1.16.1

💻 System environment

Other Linux

🌐 Browser

Chrome

🐛 Problem description

I am using logto. After configuring all environments, there is a problem with login/registration. When I click in, the following error appears: [auth][error] UnknownAction: Cannot parse action at /api/auth/session .Read more at https://errors.authjs.dev#unknownaction at /app/.next/server/chunks/35411.js:1:36999 at tx (/app/.next/server/chunks/35411.js:1:37314) at im (/app/.next/server/chunks/35411.js:357:46362) at t (/app/.next/server/chunks/35411.js:357:56511) at /app/nodemodules/.pnpm/next@14.2.9@babel+core@7.23.6_supports-color@8.1.1@opentelemetry+api@1.9.0_react-dom@18.3._5qe6vzi7lz36zngmhhqssoddee/node_modules/next/dist/compiled /next-server/app-route.runtime.prod.js:6:36938 at /app/nodemodules/.pnpm/next@14.2.9@babel+core@7.23.6_supports-color@8.1.1@opentelemetry+api@1.9.0_react-dom@18.3._5qe6vzi7lz36zngmhhqssoddee/node_modules/next/dist/server /lib/trace/tracer.js:140:36 at NoopContextManager.with (/app/node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js:25:19) at ContextAPI.with (/app/node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/src/api/context.js:60:46) at NoopTracer.startActiveSpan (/app/node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js:65:31) at ProxyTracer.startActiveSpan (/app/node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.js:36:24) image logto configuration: image Lobe service environment configuration:

image

📷 Steps to reproduce

No response

🚦 Expected results

No response

📝 Supplementary information

No response

dosubot[bot] commented 1 week ago

To resolve the "UnknownAction: Cannot parse action at /api/auth/session" error in your Next.js application using Logto for authentication, ensure that the following environment variables are correctly configured:

  1. NEXT_AUTH_SECRET: This is required to encrypt Auth.js session tokens. You can generate a key using the command:

    openssl rand -base64 32
  2. NEXT_AUTH_SSO_PROVIDERS: Set this to logto to select Logto as the single sign-on provider for LobeChat.

  3. LOGTO_CLIENT_ID: The Client ID from the Logto App details page.

  4. LOGTO_CLIENT_SECRET: The Client Secret from the Logto App details page.

  5. LOGTO_ISSUER: The OpenID Connect issuer of the Logto provider. This should be:

    • https://lobe-auth-api.example.com/oidc if you are using a privately deployed Logto.
    • https://example.logto.app/oidc if you are using Logto Cloud.
  6. NEXTAUTH_URL (Optional): This URL specifies the callback address for Auth.js during OAuth verification, needed only if the default generated redirect address is incorrect. For example:

    https://lobe.example.com/api/auth

Ensure these environment variables are set correctly in your LobeChat environment configuration. Here is an example of how to set them:

NEXT_AUTH_SECRET=your_generated_secret
NEXT_AUTH_SSO_PROVIDERS=logto
LOGTO_CLIENT_ID=your_logto_client_id
LOGTO_CLIENT_SECRET=your_logto_client_secret
LOGTO_ISSUER=https://example.logto.app/oidc
NEXTAUTH_URL=https://lobe.example.com/api/auth

After setting these variables, redeploy your application to apply the changes. This should resolve the "UnknownAction: Cannot parse action at /api/auth/session" error [1][2].

To continue talking to Dosu, mention @dosu.

yincangshiwei commented 6 days ago

还是不行,我把NEXTAUTH_URL改回https://lobe服务域名/api/auth了,之前是https://lobe服务域名/api/auth/callback/logto导致出现这个错误,但我改回https://lobe服务域名/api/auth,出现另一个错误。 image 配置也没问题: image

lobehubbot commented 6 days ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Still not working, I changed NEXTAUTH_URL back to https://lobe service domain name/api/auth. It used to be https://lobe service domain name/api/auth/callback/logto, which caused this error, but I changed it back to https:/ /lobe service domain name/api/auth, another error occurred. image

yincangshiwei commented 6 days ago

Is it possible that the Logto dev version still doesn't have that and you need to purchase the Pro version?

yincangshiwei commented 6 days ago

I switched to GitHub and encountered another error, which seems to be a network issue: image

yincangshiwei commented 6 days ago

I found that Chinese Mainland's use of these are not very good

cy948 commented 1 day ago

fetch failed 是网络问题。