wordpressmobilenavigation

Mobile wordpress menu not responsive


On WordPress 2024 theme - my mobile menu nav does not open. https://07i.c46.myftpupload.com/

In console I'm getting the following JS errors:

GET https://07ic46.p3cdn1.secureserver.net/wp-includes/js/dist/interactivity.min.js?time=1728611306&ver=6.6.2 net::ERR_FAILED 200 (OK)

Access to script at 'https://07ic46.p3cdn1.secureserver.net/wp-includes/blocks/navigation/view.min.js?time=1728611306&ver=6.6.2' from origin 'https://07i.c46.myftpupload.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. 07i.c46.myftpupload.com/:232 
        
         GET https://07ic46.p3cdn1.secureserver.net/wp-includes/blocks/navigation/view.min.js?time=1728611306&ver=6.6.2 net::ERR_FAILED 200 (OK)

Unsure as how to fix this. I've tried delaying JS scripts which hasn't worked.


Solution

  • It looks like you're facing two issues:

    You can get solution from here

    1. CORS Policy Block: The error blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present indicates that the resource at https://07ic46.p3cdn1.secureserver.net is being blocked because of missing CORS headers.

    To fix this, you need to add the Access-Control-Allow-Origin header to allow cross-origin requests. If you have access to the server where the requested resources are hosted, you can add this to your .htaccess file:

    <IfModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
    </IfModule>
    

    This will allow all origins to access your resources. You can restrict this by replacing the * with your domain for security.

    2. JavaScript Files Failing to Load: The GET net::ERR_FAILED error suggests that the necessary JavaScript files for your mobile menu aren’t loading properly. This can happen if there’s a mismatch between your site's URLs or issues with your CDN.

    Steps to fix this:

    Check WordPress URL settings: Go to Settings > General and ensure both "WordPress Address" and "Site Address" are set correctly and consistently (i.e., using the same domain and protocol). Manually enqueue scripts: If the issue persists, try deregistering and re-enqueueing the navigation script by adding the following code to your theme’s functions.php:

    function my_custom_enqueue_scripts() {
        wp_deregister_script('wp-block-navigation-view');
        wp_register_script('wp-block-navigation-view', get_template_directory_uri() . '/wp-includes/blocks/navigation/view.min.js', array(), '6.6.2', true);
        wp_enqueue_script('wp-block-navigation-view');
    }
    add_action('wp_enqueue_scripts', 'my_custom_enqueue_scripts');
    

    Clear cache and CDN: If you’re using a CDN or caching plugin, clear the cache. You might want to temporarily disable the CDN to check if it’s causing the issue.