在我的nginx配置$ http_origin中为空字符串

问题描述 投票:0回答:1

我什至尝试过类似愚蠢的事情:

add_header 'Access-Control-Allow-Origin' "http://loca${http_origin}lhost:3000";

并且结果仅为http://localhost:3000,因此为空。为什么?

nginx access-control
1个回答
1
投票

我认为浏览器不会发送带有名为“ Origin”的标头的请求。因此,您的nginx无法获得$ http_origin

$http_origin的意思是“获取请求的标头:起源”

您可以尝试以下方法:

curl localhost:3000 -H "origin: google.com"

$http_xxx变量是请求的标头

ref:https://nginx.org/en/docs/http/ngx_http_core_module.html#var_http_

© www.soinside.com 2019 - 2024. All rights reserved.