logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Access To Website Blocked By CORS Policy
Author
apishdad



Joined: 01 Jul 2019
Posts: 44
Location: Canada, Toronto

PostPosted: Tue 22 Oct '24 16:27    Post subject: Access To Website Blocked By CORS Policy Reply with quote

Hi,
I am getting the following error for CORS policy and below is my configuration in my .conf file.

The error is :

Access to XMLHttpRequest at 'https://mywebsite.com/dir1/api/login' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.


I am just showing below the sections that relate to CORST policy. I cant post the whole virtualhost because its too long.


<VirtualHost 10.36.1.2:443>
ServerName mywebsite.com

Header always set X-XSS-Protection "1; mode=block"
Header always set X-Content-Type-Options nosniff
Header always set X-Frame-Options DENY
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
Header always set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
Header always set Pragma "no-cache"

#---------------------------------------------------------------------CORS POLICY--------------------------------------------------------------------
SetEnvIf Origin "http(s)?://(www\.)?(q-iris.awsdev-univeris.com|website1.com|website2.com|allotherwebsites.com|etc,etc.com)$" AccessControlAllowOrigin=$0
Header set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header append Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT, HEAD"
Header append Access-Control-Max-Age "600"
Header append Access-Control-Allow-Headers "x-requested-with, Content-Type, Authorization, origin, accept, x-api-key"
Header append Access-Control-Allow-Credentials "true"


</VirtualHost>


Your response is greatly appreciated.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7374
Location: Germany, Next to Hamburg

PostPosted: Thu 07 Nov '24 12:21    Post subject: Reply with quote

it seems that Access-Control-Allow-Origin is not set correctly.

Can you open the developer tools in your browser and see a more detailed error message?
Back to top


Reply to topic   Topic: Access To Website Blocked By CORS Policy View previous topic :: View next topic
Post new topic   Forum Index -> Apache