应用程序配置不允许给定 URL:本地主机


Given URL is not allowed by the Application configuration.: localhost

我正在localhost测试我的应用程序。当我点击fb登录时,我收到一个错误

> Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.

我提到了这个问题,但它是关于在线申请的。在这里,我想在本地测试它。我应该在应用程序域中提供什么?

我的应用程序名称说http://localhost/fblogin.,应该redirect_url什么?

我试图给应用程序域http://localhost/fblogin但它给了我这样的错误

> App Domains: `https://localhost/fblogin` should not contain protocol information.

我只能通过设置虚拟主机URL在本地测试Facebook应用程序。如果您不熟悉虚拟主机,基本效果是,当您将计算机上的任何浏览器指向您选择的某个 URL(如果需要,可以 www.yahoo.com)时,它会指向本地目录,而不是在互联网上查找该 URL。通过这种方式,您将能够为Facebook提供所需的 http://URL,同时保持本地。我能够使用以下教程在Mac上设置虚拟主机。

我建议您添加一个开发子域并将其指向本地主机。

在 Mac OSX 中编辑终端中的/etc/hosts

sudo vi /etc/hosts

然后将以下行添加到文件末尾(相应地替换"mydomain.com")

127.0.0.1 dev.mydomain.com

然后保存,按电调键

:wq

然后刷新缓存

dscacheutil -flushcache

现在将该域添加到您的Facebook应用程序域

MyFacebookApp -> Settings -> Basic -> App Domains

现在而不是使用

http://localhost:3000 

要测试您的应用,请尝试

http://dev.mydomain.com:3000 

(假设端口 3000)

应该工作:)