nginx has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `local`.
时间: 2023-12-20 16:31:21 浏览: 238
nginx被CORS策略阻止的原因是请求客户端不是安全上下文,并且资源在更私有的本地地址空间中。解决此问题的一种方法是在nginx配置文件中添加以下内容:
```nginx
location / {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
```
这将允许所有来源的请求访问nginx服务器,并允许使用GET,POST和OPTIONS方法。此外,还将允许使用特定的请求头。
阅读全文
相关推荐













