I have OmniAuthable Facebook login on my website. Users login with:
link_to user_omniauth_authorize_path(:facebook)
It is defined in app config at developers.facebook.com.
If I access the website through http://www.example.com, everything works ok and I can login.
If I access it without the “www” subdomain (i.e. example.com), I get the following response:
{
"error": {
"message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
"type": "OAuthException"
}
}
Does anybody know how I can fix this?
Solution: don’t do that. You will end up with all sorts of problems (see this page). Choose to use either
www.example.comorexample.comand enforce it in your application by redirecting from the disallowed version to the desired one. FWIW, Google chooses to usewwwbecause it is more compatible with their architecture (indeed, it’s more flexible). StackOverflow on the other hand chooses to go without it (it’s canonically more accurate). Either way, pick one and stick with it.