Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
Apache / Tomcat - Access-Control-Allow-Origin Header not set

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

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!