在响应中添加来自请求的源头到访问控制

发布于 2025-02-13 07:21:10 字数 283 浏览 0 评论 0原文

我想允许所有rigins从我的Apache服务器获取资源。

而不是添加:

Access-Control-Allow-Origin: *

我希望我的服务器可以通过以下特殊的响应来制作:

Access-Control-Allow-Origin: <the value of the Origin received in the request>

我可以添加到httpd.conf的东西来实现这一目标吗?

I'd like to allow all origins to fetch resources from my apache server.

Instead of adding:

Access-Control-Allow-Origin: *

I would like my server to craft a special response with :

Access-Control-Allow-Origin: <the value of the Origin received in the request>

Is there something I can add to httpd.conf to achieve this ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

顾铮苏瑾 2025-02-20 07:21:10

似乎可以通过添加这两条线来实现:

SetEnvIf Origin ".*\S.*" ORIGIN=$0
Header always set Access-Control-Allow-Origin %{ORIGIN}e env=ORIGIN

正则差距意味着除了newline,Tab和Space以外的任何内容,因此只要原点不为空,将其添加到响应标头中。

Seems it can be achieved by adding those two lines:

SetEnvIf Origin ".*\S.*" ORIGIN=$0
Header always set Access-Control-Allow-Origin %{ORIGIN}e env=ORIGIN

The regex pretty much means anything except newline, tab, and space, so as long as the Origin is not empty add it to the response header.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文