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: How enable CORS on Apache in WHM
Adding this to the htaccess file:
Header set Access-Control-Allow-Origin "*"
I then tried:
Header always set Access-Control-Allow-Origin "blog.webhost.pro"
--
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
--
nano /etc/apache2/conf.d/userdata/ssl/2_4/username/domain.com/yourinclude.conf
With the site info and headers added and rebuilt apache
--
<ifModule mod_headers.c>
Header set Access-Control-Allow-Origin: *
</ifModule>
# Images and General graphics
<FilesMatch "\.(gif|png|jpe?g|svg|svgz|ico|webp)$">
SetEnvIf Origin ":" IS_CORS
Header set Access-Control-Allow-Origin "*" env=IS_CORS
# Webfons
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css|woff2)$">
Header set Access-Control-Allow-Origin "*"
This one crashed the site.
--
Add this to the function.php page:
<?php
header("Access-Control-Allow-Headers: Authorization, Content-Type");
header("Access-Control-Allow-Origin: *");
header('content-type: application/json; charset=utf-8');
?>
--
add_action('init', 'handle_preflight');
function handle_preflight() {
$origin = get_http_origin();
if ($origin === 'yourdomain.com') {
header("Access-Control-Allow-Origin: yourdomain.com");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header("Access-Control-Allow-Credentials: true");
header('Access-Control-Allow-Headers: Origin, X-Requested-With, X-WP-Nonce, Content-Type, Accept, Authorization');
if ('OPTIONS' == $_SERVER['REQUEST_METHOD']) {
status_header(200);
exit();
}
}
}
----------------------------------
Nothing would get the icon images to load on our new blog theme:
Web Host Pro You can see it in the menu drop down. The theme maker said it's a cPanel issue with CORS but I'm stumped on how to fix this.
Thanks!
I tried this thread first: How enable CORS on Apache in WHM
Adding this to the htaccess file:
Header set Access-Control-Allow-Origin "*"
I then tried:
Header always set Access-Control-Allow-Origin "blog.webhost.pro"
--
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
--
nano /etc/apache2/conf.d/userdata/ssl/2_4/username/domain.com/yourinclude.conf
With the site info and headers added and rebuilt apache
--
<ifModule mod_headers.c>
Header set Access-Control-Allow-Origin: *
</ifModule>
# Images and General graphics
<FilesMatch "\.(gif|png|jpe?g|svg|svgz|ico|webp)$">
SetEnvIf Origin ":" IS_CORS
Header set Access-Control-Allow-Origin "*" env=IS_CORS
# Webfons
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css|woff2)$">
Header set Access-Control-Allow-Origin "*"
This one crashed the site.
--
Add this to the function.php page:
<?php
header("Access-Control-Allow-Headers: Authorization, Content-Type");
header("Access-Control-Allow-Origin: *");
header('content-type: application/json; charset=utf-8');
?>
--
add_action('init', 'handle_preflight');
function handle_preflight() {
$origin = get_http_origin();
if ($origin === 'yourdomain.com') {
header("Access-Control-Allow-Origin: yourdomain.com");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header("Access-Control-Allow-Credentials: true");
header('Access-Control-Allow-Headers: Origin, X-Requested-With, X-WP-Nonce, Content-Type, Accept, Authorization');
if ('OPTIONS' == $_SERVER['REQUEST_METHOD']) {
status_header(200);
exit();
}
}
}
----------------------------------
Nothing would get the icon images to load on our new blog theme:
Web Host Pro You can see it in the menu drop down. The theme maker said it's a cPanel issue with CORS but I'm stumped on how to fix this.
Thanks!
Last edited by a moderator: