Angularjs 如何在Wamp中访问控制允许原点?
在测试Angular应用程序时,我使用Wamp作为本地服务器 我正在使用$resource从我的服务器获取一些api数据,但我收到一条消息Angularjs 如何在Wamp中访问控制允许原点?,angularjs,Angularjs,在测试Angular应用程序时,我使用Wamp作为本地服务器 我正在使用$resource从我的服务器获取一些api数据,但我收到一条消息 XMLHttpRequest cannot load http://myproj.herokuapp.com/api/projects?name=demo. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://loc
XMLHttpRequest cannot load http://myproj.herokuapp.com/api/projects?name=demo.
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 401.
我已经在网上搜索了很多地方,但是我找不到一个有效的方法来解决这个问题
有什么新的想法吗?有人克服了这个问题吗
这位作者说得对。
您必须首先启用headers模块,如下所示:
单击systray中的wamp图标
转到Apache>Apache模块
选中选项“标题\u模块”
然后将其包含在apache配置中:
标题集访问控制允许原点:*
在httpd.conf或vhost的配置中
您还可以指定特定的域,而不是*号
然后打开浏览器,使用localhost/filename访问文件