Reputation: 15802
I'm trying to develop a website which uses Facebook Connect for authentication and other things. However, it seems that FBConnect in general requires the URL of the website to be the same one as you registered the app with. This is a problem, because although I'm running the site at
www.example.com
i am testing the site at
localhost:9000
So all the facebook stuff breaks on my local machine. Currently I'm simply working around this by doing testing on the actual server. So each time I want to test my code after doing stuff, I perform a
// local machine
git commit -a
git push origin master
// remote server
git pull origin master
Which apart from being annoying to do for every small change, is obviously going to be a problem when real people are actually reaching the website, and I want to continue development & testing without breaking it over and over while people are using it.
Is there a better way of doing this sort of thing? I'm sure others (i.e. everyone else who has ever used FBConnect) have run into this problem before. Is it possible to trick my DNS to point www.example.com
at localhost
during testing, so the Facebook Javascript is tricked to continue working?
Upvotes: 4
Views: 910
Reputation: 665
The real answer here is to set up a staging server not located on your own localhost and create a staging application in FB pointing to that staging URL.
I like to use an entirely separate server for this purpose so I can develop and experiment at will without worrying about crashing my production application due to an errant loop or something. --or-- Create a subdomain (staging.example.com) and stick a clone of your code in a separate root folder with the same directory structure as your application.
Yes, you will need some small conditional code to determine if you're looking at the staging or the production version of your site and then call the appropriate FB keys accordingly.
Upvotes: 2
Reputation: 2077
I ran into this problem when trying to move my code from development (localhost) to production. I was able to use localhost as the canvas url and my production domain for the secure canvas url. That way I was able to
Upvotes: 0
Reputation: 4527
One way around this is to edit your system's hosts file to point your domain to localhost. Add a line like this to your /etc/hosts
file (or %SystemRoot%\system32\drivers\etc\hosts
on windows):
127.0.0.1 www.yourdomain.com
Another approach is to create a second app on facebook for you in-development version, and use localhost
as the URL for that version. Just don't forget to update the app id and secret to the production version when you deploy :)
Upvotes: 3