Access to fetch has been blocked by CORS policy

From Kolmisoft Wiki
Jump to navigationJump to search

If you see such an error:

Access to fetch at 'https://yourdomain.com/billing/api/user_calls_get?u=admin&hash=a1b2c3f4s5f6h7j8k9' from origin 'http://127.0.0.1:5500' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

add this line to /etc/httpd/conf.d/gui_ssl.conf

   ...
   ...
   <Directory /var/www/html/billing>
       Options -MultiViews
       Header set Access-Control-Allow-Origin http://127.0.0.1:5500
   </Directory>
   ...
   ...

Source:

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSAllowOriginNotMatchingOrigin