So no shit, there you are, building a web app that is using the Facebook SDK/API. You’ve followed all the integration tutorials. You’ve got all the code in place. You’re ready to go. You fire up the Sidekiq and your Rails server with Foreman, and you finally click on your pretty little Facebook login button. And then…
Then you want to punch yourself. Why didn’t I put localhost into the app domains? I better go ahead and do that. You log into Facebook and put localhost in there. And then…
Ok Facebook… So WHAT THE HELL DO I DO THEN?
Scratched my head for a few minutes. Started thinking about how soon until it was drinking time, and then had a thought. Why not just locally redirect the production URL to my machine? The app will then send requests with a production URL referrer and will be authorized by Facebook’s dumb ass security schemes. (Ok maybe not dumbass but certainly inconvenient. I’m trying to work here!)
- Add the production URL to your /etc/hosts file and redirect back to localhost
After you change your hosts file on a Mac you always have to flush the cache and force OSX to re-query the DNS servers. Run this command and you should be good to go.
Now, have a beer and relax before you kill somebody. This shit can get stressful.