LoginSignup
0
0

More than 1 year has passed since last update.

本番環境でgoogle認証ログインができない時の解決方法

Last updated at Posted at 2021-09-15

はじめに

本番環境にて、google認証ログインを行った時以下のようなエラーが発生した。

結論

原因としては、本番環境にclient_idが記述された.envが存在していないことだった。
本番環境にも.envを作成すると、google認証することができた。

しかし、自分は.envはgithubに上げないようにしているため、デプロイすると再び.envが読めなくなり、google認証できなくなってしまう。
そのため、デプロイ時に毎回.envを本番環境に作成しなくてもいいようタスクを作成した。

#capfile
namespace :deploy do
  desc "upload env"
  task :sync_env do
    on roles(:app) do |host|
      upload! ".env","#{shared_path}/.env" #デプロイ時、shereフォルダへローカルの.envをコピー(※大切な情報のためcurrentよりもsharedに入れたほうがいいらしいので)
      execute "ln -s #{shared_path}/.env #{current_path}/.env" #currentではなく、sharedの.envを参照させる
    end
  end
end
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