LoginSignup
0
0

More than 1 year has passed since last update.

Next.js 13 ( appDir ) + Vercel + nextjs-auth0 v2.0.0 で発生するエラー(2023/02/11時点)

Last updated at Posted at 2023-02-11

概要

  • Next.js 13でAuth0の設定をして、VercelにDeployしたら、エラーが出たので、その対策まとめ。

状況

  • ローカル環境では、Auth0でログイン・ログアウトができるが、Vercelにデプロイされたサービスでログインするとエラーが発生する。

発生したエラー

Login handler failed. CAUSE: Discovery requests failing for https://dev-94xpl1w2.us.auth0.com, Unexpected token / in JSON at position 0

このエラーで検索すると、Auth0の設定値にミスがあるから発生する、という記事はいくつかありました。

再度、設定値を見なしても、不備はなく、頭を抱える……

原因

現時点で、nextjs-auth0 の ver.2.0.0 以降はNext.js 13の appDirモードは非推奨でした。nextjs-auth0のver.1系からver.2系へのアップデートで大きな変更があったようです。

The app directory introduced with Next.js 13 is currently in beta, and Vercel does not recommend using it in production. As such, this SDK does not support it yet.

対策

v1系の最終バージョン、v1.9.2 にダウングレードすることで、vercelでも動くようになりました。

$ npm install @auth0/nextjs-auth0@1.9.2 

補足

CloudRunやAppRunnerでは試していませんが、vercelでは一旦、ダウングレードして様子見になりそうかなと思いました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0