1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Next.js/Docker Rails】コンテナ内で環境変数が読み込まれないエラーの解決方法について

Posted at

はじめに

フロント側Nextjsからバックエンド側RailsへAPIリクエストするも、.envが読み込まれておらず認証が失敗しているエラーでつまずいたため記事にします。
 ローカルで.envを作成すればコンテナ内でも環境変数を使うことができると思っておりました。

APIからの返り値

{message: 'Unauthorized', type: 'unauthorized'}

解決方法

下記を追加

docker-compose.yml
env_file:
  - .env

参考

おわりに

bashでも環境変数が使えることを確認して、値も取得できるようになりました。


JISOUのメンバー募集中!

プログラミングコーチングJISOUでは、新たなメンバーを募集しています。
日本一のアウトプットコミュニティでキャリアアップしませんか?
興味のある方は、ぜひホームページをのぞいてみてください!
▼▼▼

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?