CORS当客户端和放大器;服务器是本地主机? [英] CORS when both client & server are localhost?
问题描述
我试图发展与AngluarJS&放一个客户机/服务器应用程序; PHP(这可能是因为AJAX只是处理HTTP GET和从来没有真正在浏览器中显示一个页面)。
I am trying to develop a client/server app with AngluarJS & PHP (which is probably AJAX as it just handles HTTP GET and never actually displays a page in a browser).
我使用XAMPP的Apache我的本地和开发客户端在括号IDE 。括号内运行一个活preVIEW本地主机端口49883。
I use XAMPP Apache for my localhost and develop the client in the Brackets IDE. Brackets runs a "live preview" on local host port 49883.
[更新]它选择每次开机后一个新的端口,所以如果我想调整我的Apache与,然后我手动每次重新启动(益)后编辑的配置。
[Update] It chooses a new port after each reboot, so if I want to align my Apache with that, then i have manually edit the config after each reboot (ick).
当我尝试<$c$c>$http.get('http://127.0.0.1/my_script.php?action=overview_map&date=2014-04-12&user=abc')$c$c>
调试控制台显示。
无'访问控制允许来源标头的请求的资源present。因此出身http://127.0.0.1:49833'是不允许访问。
我怎样才能解决这个问题?
How can I get around this?
我把这个线在我的Windows主机文件 127.0.0.1 test_site
键,这在我的PHP结果头('访问控制允许来源:test_site
但是我还是访问控制允许原产地报头包含无效值'test_site'。
I put this line in my Windows hosts file 127.0.0.1 test_site
and this in my PHP
header('Access-Control-Allow-Origin: test_site'
but I still get The 'Access-Control-Allow-Origin' header contains the invalid value 'test_site'.
也许有一些办法让支架与 Chrome启动 - 禁用 - 网络安全
选项,这样才能有没有CORS问题可言
Perhaps there is some way to get Brackets to start Chrome with the --disable-web-security
option, so as to have no CORS problems at all?
或者另一个(免费)IDE它处理这个?
Or another (free) IDE which handles this?
这是所有新的给我,但一定有很多,很多,很多人出去与客户及放有发展;服务器(preferably与JS&安培; PHP)在本地主机上。你怎么办呢?
This is all new to me, but there must be many, many, many others out there developing with client & server (preferably with JS & PHP) on localhost. How do you do it?
在此先感谢您的帮助。
推荐答案
您正在使用不同的端口。它是受CORS。
You're using different port. It is subject to CORS.
这篇关于CORS当客户端和放大器;服务器是本地主机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!