This topic contains 2 replies, has 2 voices, and was last updated by  onyxtacular 7 months ago.

CORS policy: No ‘Access-Control-Allow-Origin’ display map not loading

  • I recently migrated to a new server. Since the migration the map does not display on the page, the only thing seen is a loading icon. Where should I start to trouble shoot.

    The console reports these errors:

    Access to XMLHttpRequest at ‘′ from origin ‘’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

    GET net::ERR_FAILED 301

    I’ve tried adding this the the wordpress functions.php file:

    add_action('init', 'handle_preflight');
    function handle_preflight() {
    $origin = get_http_origin();
    if ($origin === '') {
    header("Access-Control-Allow-Origin: yourfrontenddomain");
    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');
    add_filter('rest_authentication_errors', 'rest_filter_incoming_connections');
    function rest_filter_incoming_connections($errors) {
    $request_server = $_SERVER['REMOTE_ADDR'];
    $origin = get_http_origin();
    if ($origin !== '') return new WP_Error('forbidden_access', $origin, array(
    'status' => 403
    return $errors;

    and I’ve added this the .htaccess file:

    <IfModule mod_rewrite.c>
    Header set Access-Control-Allow-Origin "*"
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    StaffUser Level

    Hi there,

    Thank you for your inquiry, if you’re getting permission error “Access to XMLHttpRequest”, try to contact your hosting provider (for both domains) to allow access for cross origins and allow firewall, more details available in this knowldege base article here.


    The server are with the same provider. I did get the error fix though:

    The WordPress Address (URL) & Site Address (URL)
    where different (one was missing the www.)


The topic ‘CORS policy: No ‘Access-Control-Allow-Origin’ display map not loading’ is closed to new replies.