Say you’re building a Rails application and want to use Facebook with Omniauth via Devise. You’ve already got that working and have your Facebook API key registered and all that. But maybe you want to see how it works and test certain things before deploying to Production.
Facebook requires only certain domains be allowed access to your API usage. You might be able to get away with using
localhost but maybe not (I’ve not tried it, TBH) plus that is just messy.
Easy fix! Let’s say your app’s public domain is
/etc/hosts file and add an entry:
... dev.awesomeapp.com 127.0.0.1 ...
In Facebook’s API settings, add that url,
dev.awesomeapp.com to your list of “App Domains”.
If you’re using Unicorn, you may need to specify that you want to use this URL to listen on (it defaults to
$ bundle exec unicorn -l 127.0.0.1:8080
bundle exec unicorn -l dev.awesomeapp.com:8080
Either will work.
You should be able to now authenticate while in your dev environment.