mercredi 28 février 2018

Response for preflight is invalid (redirect) - Rails 5, Omniauth, Facebook login

I am following this example for Facebook login with Omniauth and Rails 5: Link to Omniauth. The problem is that, when I click on the link for login, right before redirects to Facebook, I am getting this error in the console (2 times):

Failed to load https: // http://ift.tt/2CPCWv7 Response for preflight is invalid (redirect)

This is my view:

<%= link_to 'FB LOGIN', user_facebook_omniauth_authorize_path %>

which is this HTML:

<a href="/auth/facebook">FB LOGIN</a>

and point to this omniauth_callbacks_controller:

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController

  def create
    byebug
    @user = User.from_omniauth(request.env["omniauth.auth"])
....

I have byebug in this method, but this does not matter. With or without it, I am getting same error in the browser, before redirecting.

I think the error is because it redirects to Facebook first, but I don't know how to fix it.

Aucun commentaire:

Enregistrer un commentaire