Scenario ::
Tomcat WAR File with Root Context - /RootContext
Static files on - /static -> */apache-htdocs/static/
https://example.com/RootContext/api ==> Served from Tomcat
https://example.com/static/js.hs ==> Served from Apache HTDOCS
Apache Configuration ::
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"
Tried this too
<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>
What works :: Anything poiting to /static ==> Directly from htdocs
http://example.com/static/static.js ==> has been blocked by CORS policy:
What doesnt work :: Anything poiting to /RootContext
http://example.com/RootContext/api/v1/getsomething ==> Does not apply Access-Control-Allow-Origin header
Any clues ?
I want to do it within apache only