![](/img/trans.png)
[英]Devise Google Omniauth working in Local, but not in Production
[英]Rails 6 omniauth working on local but not production (Heroku)
我有一個:
身份驗證失敗:#<Hash.... 的未定義方法“bytesize”...
這是我的鏈接的樣子:
<%= link_to t('navbar.loginf'), user_facebook_omniauth_authorize_path, method: :post, class: "is-fullwidth" %>
<%= link_to t('navbar.loging'), user_google_oauth2_omniauth_authorize_path, method: :post, class: "is-fullwidth" %>
這是 omniauth controller:
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
@user = User.from_omniauth(request.env['omniauth.auth'])
if @user.persisted?
sign_in_and_redirect @user, event: :authentication # this will throw if @user is not activated
set_flash_message(:notice, :success, kind: 'Facebook') if is_navigational_format?
else
session['devise.facebook_data'] = request.env['omniauth.auth']
redirect_to new_user_registration_url
end
end
def google_oauth2
@user = User.from_omniauth(request.env['omniauth.auth'])
if @user.persisted?
sign_in_and_redirect @user
set_flash_message(:notice, :success, kind: 'Google') if is_navigational_format?
else
flash[:error] = I18n.t('alert.gge')
redirect_to new_user_registration_url
end
end
def failure
redirect_to root_path
end
end
查找問題:
-必須更新 yarn.lock 文件(刪除 yarn.lock 文件並在終端上運行 yarn install 命令,它將生成一個新的 yarn.lock )
-此版本在 heroku 上有所不同
"@babel/parser@^7.16.7", "@babel/parser@^7.17.3":
-Google 回調調用 JS 文件以使用我們請求的參數點擊操作。
- 所以 Omniauth 需要解析它但它不能這樣做,因為 babel 沒有正確解析它並將它交給 omniauth.rb 的 auth_hash 方法
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.