🌊

sidebase/nuxt-authをproduction環境で使う際のTips

2024/02/12に公開

概要

sidebase/nuxt-authをproduction環境で使う際の注意点に関する備忘録です。

sidebase/nuxt-authは、Nuxt 3 アプリケーション向けの認証モジュールです。

https://github.com/sidebase/nuxt-auth

問題

VercelやAWS Amplifyにデプロイした際、以下のメッセージとともに、サーバエラーが発生しました。

AUTH_NO_ORIGIN: No `origin` - this is an error in production, see https://sidebase.io/nuxt-auth/resources/errors. You can ignore this during development

対策

以下が参考になりました。

https://github.com/sidebase/nuxt-auth/issues/613

以下のようにbaseURLを与えることで、上記のエラーを解消できました。

nuxt.config.ts
auth: {
      baseURL: process.env.AUTH_ORIGIN,
  },

改めて確認すると、以下に記載がありましたが、なかなかたどり着くことができませんでした。

https://sidebase.io/nuxt-auth/configuration/nuxt-config#provider-authjs-baseurl

まとめ

同様の事象でお困りの方の参考になりましたら幸いです。

Discussion