2017-06-17 21 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

它可以在主機上使用 –