场景::
具有根上下文的 Tomcat WAR 文件 - /RootContext
静态文件 - /static
-> */apache-htdocs/static/
https://example.com/RootContext/api ==> 由 Tomcat 提供
https://example.com/static/js.hs ==> 由 Apache HTDOCS 提供
Apache 配置 ::
JKMount /RootContext worker1
<Directory /perfios/apache-htdocs>
DirectoryIndex index.php index.html
Options FollowSymLinks MultiViews
AllowOverride None
Require all granted
Header set access-control-allow-origin "http://example.com"
</Directory>
Header always append access-control-allow-origin: "http://example.com"
Header always set access-control-allow-origin "http://example.com"
也试过这个
<IfModule mod_deflate.c>
# CORS
SetEnvIfNoCase Origin "http(s)?://(\w+\.)?(example.com)(:[0-9]+)?$" accessControlAllowOrigin=$0
Header set access-control-allow-origin %{accessControlAllowOrigin}e env=accessControlAllowOrigin
Header set access-Control-Allow-Credentials true
</IfModule>
什么是有效的 :: 任何指向 /static ==> 直接来自 htdocs
http://example.com/static/static.js ==> 已被 CORS 政策阻止:
什么不起作用 :: 指向 /RootContext
http://example.com/RootContext/api/v1/getsomething ==> 不应用 access-control-allow-origin 标头
有什么线索吗?
我只想在 apache 中做