19

Been trying to setup my Facebook app which I want to use for Logins to allow me to test it on my Mac's localhost. Facebook is throwing the error "App Domain: http://localhost is not a valid domain." when I try change App Domain of Site URL to localhost or 127.0.0.1

IS there any way to get the facebook login api to redirect the browser to my localhost after authentication?

abraham
  • 46,583
  • 10
  • 100
  • 152
John Cogan
  • 1,034
  • 4
  • 16
  • 39
  • possible duplicate of [Running Facebook application on localhost](http://facebook.stackoverflow.com/questions/5133075/running-facebook-application-on-localhost) – ifaour Mar 05 '12 at 09:36
  • possible duplicate of [Facebook development in localhost](http://stackoverflow.com/questions/4532721/facebook-development-in-localhost) – Chris Moschini Aug 12 '14 at 23:05
  • possible duplicate of http://stackoverflow.com/questions/2459728/how-to-test-facebook-connect-locally/25560146#25560146 – Snowman May 27 '16 at 19:09

3 Answers3

17

The way I do it is alias the site I'm working on to something like: http://sitename.loc, and then setup an app used specifically for testing with that as the domain.

An example of how to do this can be found here: https://stackoverflow.com/a/7493806/1056965

Community
  • 1
  • 1
Steven
  • 1,107
  • 1
  • 8
  • 21
7

On your local machine you have to setup hosts file to point your site name on local ip address. For example if you have to setup authorization with fb on site example.com put this record in your hosts file

127.0.0.1 example.com

And just start your site localy and facebook oauth will redirect you on example.com and you will get valid token localy.

For setup hosts file on windows help is on this link Windows Hosts Setup Linux help link Linux hosts

Kalanj Djordje Djordje
  • 1,162
  • 1
  • 12
  • 15
3

It's simple enough when you find out.

Open /etc/hosts (unix) or C:\WINDOWS\system32\drivers\etc\hosts.

If your domain is foo.com, then add this line:

127.0.0.1 local.foo.com When you are testing, open local.foo.com in your browser and it should work.

Allready, explained here

How to Test Facebook Connect Locally

Community
  • 1
  • 1
Dinesh Patil
  • 1,042
  • 10
  • 13