2017-06-17 72 views
0

我使用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”仅仅是一个随机的网址,这个网址我每次访问使用remot3设备时间的变化。我想我必须允许任何域/ URL的来源来调用web服务。

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

回答

0

必须设置在Web服务器

在appache服务器放在

的.htaccess文件并启用模头

<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> 
+0

我需要它添加到右侧被称为服务器?这意味着托管在云端的服务器? –

+0

它可以在主机上使用 –