1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

JWT認証を外部サーバーで実装する時に詰まった話

Posted at

#はじめに

開発環境
- Heroku
- PHP
  - laravel

もちろんローカルでは動作確認済み。

#詰まったところ

どうやらJWT認証がうまくいかない。

#解決法

jwtの秘密鍵が登録されていなかったからエラーが出た。
外部サーバーにも秘密鍵を登録する。

$ heroku run php artisan jwt:secret
Running php artisan jwt:secret on ⬢ アプリ名... up, (省略)
jwt-auth secret [ 秘密鍵 ] set successfully.

ローカル環境なら環境変数も .env に自動で登録してくれるのだが、外部サーバーでは .env を読み込んでくれないので手動で登録する。

$ heroku config:set \
> JWT_SECRET=秘密鍵
Setting JWT_SECRET and restarting ⬢ アプリ名... done, v17
JWT_SECRET: 秘密鍵

これでJWT認証が使えるようになった。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?