任何域的Access-Control-Allow-Origin

时间:2017-06-17 09:16:05

标签: php web-services

我使用remot3.it访问互联网上设备上托管的一些网络服务器。 Remot3为访问这些设备分配随机URL。托管在这些设备上的某些网页需要调用我在云服务器上托管的Web服务。但是,当我尝试调用这些服务时,我收到以下错误:

The 'Access-Control-Allow-Origin' header has a value 'http://hasconpanel.ckoysolutions.com' that is not equal to the supplied origin. Origin 'https://aatqtezo.p72.rt3.io' is therefore not allowed access.

" aatqtezo.p72.rt3.io"只是一个随机URL,每次使用remot3访问设备时,此URL都会更改。我想我必须允许来自任何域/ URL的来源来调用web服务。

如何设置header('Access-Control-Allow-Origin: ');以允许来自任何网站的来电?

1 个答案:

答案 0 :(得分:0)

您必须设置在Web服务器

在appache服务器中输入 .htaccess 文件并启用 mod标题

<ifModule mod_headers.c>
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
</ifModule>