![](/img/trans.png)
[英]The 'Access-Control-Allow-Origin' header with apache
[英]Add the Origin from the requests to the Access-Control-Allow-Origin header in the response
我想允許所有來源從我的 apache 服務器獲取資源。
而不是添加:
Access-Control-Allow-Origin: *
我希望我的服務器制作一個特殊的響應:
Access-Control-Allow-Origin: <the value of the Origin received in the request>
有什么我可以添加到 httpd.conf 來實現的嗎?
似乎可以通過添加這兩行來實現:
SetEnvIf Origin ".*\S.*" ORIGIN=$0
Header always set Access-Control-Allow-Origin %{ORIGIN}e env=ORIGIN
正則表達式幾乎意味着除換行符、制表符和空格之外的任何內容,因此只要 Origin 不為空,請將其添加到響應標頭中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.