Can't get CORS to work
Well I've tried 8 different way to enable CORS now and nothing. Hopefully someone here can shed some light.
I tried this thread first:
Header set Access-Control-Allow-Origin "*"
--
nano /etc/apache2/conf.d/userdata/ssl/2_4/username/domain.com/yourinclude.conf
With the site info and headers added and rebuilt apache
--
Header set Access-Control-Allow-Origin: *
# Images and General graphics
SetEnvIf Origin ":" IS_CORS
Header set Access-Control-Allow-Origin "*" env=IS_CORS
# Webfons
Header set Access-Control-Allow-Origin "*"
This one crashed the site.
--
Add this to the function.php page:
--
add_action('init', 'handle_preflight');
function handle_preflight() {
$origin = get_http_origin();
if ($origin === '
-
There is also a test at that site you can use after you'd added the .htaccess entry: test-cors.org 0 -
You wouldn't happen to know how that tool works do you? It just gives an output. My output was: Sending GET request to blog.webhost.pro Fired XHR event: loadstart Fired XHR event: readystatechange Fired XHR event: readystatechange Fired XHR event: progress Fired XHR event: readystatechange Fired XHR event: load XHR status: 200 XHR status text: XHR exposed response headers:cache-control: public, max-age=600 content-encoding: gzip content-type: text/html date: Mon, 26 Sep 2022 20:48:21 GMT etag: "1rO4KQ" expires: Mon, 26 Sep 2022 20:58:21 GMT server: Google Frontend x-cloud-trace-context: 91b55200c81f54fbb0cc51f395afd2d2 Fired XHR event: loadend 0 -
No, unfortuantely I have no other details about that tool. Are those the headers you are expecting? If not, it might be best to submit a ticket to our team so we can check your specific machine's Apache headers to see what the issue may be. 0
Please sign in to leave a comment.
Comments
4 comments