【发布时间】:2017-11-25 04:11:19
【问题描述】:
我有一个 Angular 4 应用程序与驻留在 WAMP(www 文件夹)上的 php 脚本交谈,它们都在我的本地计算机上。当我点击脚本时,我在浏览器中记录了这个错误。
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:4200' is therefore not allowed access.
The response had HTTP status code 404.
我知道这是因为我试图从 localhost 访问到 localhost 会发生此问题。
我做了一些阅读,看来我需要从 wamp 服务器修复它。不知道如何在 wamp 上做到这一点。
【问题讨论】:
-
您需要在您的服务器响应中设置标头以允许
"*" -
我如何在 apache 上做到这一点
-
好吧,工作...请作为答案。