• Hi

    I have set the facebook capi with GTM and on the console errors I have these issues on the homepage :

    Access to XMLHttpRequest at 'https://gtm.runayaq.com/data?v=1&event_name=page_view' from origin 'https://www.runayaq.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.


    POST https://gtm.runayaq.com/data?v=1&event_name=page_view net::ERR_FAILED 503 (Service Unavailable)

    XHR failed loading: POST "https://gtm.runayaq.com/data?v=1&event_name=page_view".

    Access to XMLHttpRequest at 'https://gtm.runayaq.com/data?v=1&event_name=view_item' from origin 'https://www.runayaq.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.


    POST https://gtm.runayaq.com/data?v=1&event_name=view_item net::ERR_FAILED 503 (Service Unavailable)

    XHR failed loading: POST "https://gtm.runayaq.com/data?v=1&event_name=view_item".

    how could that be fixed ?

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello there,

    Your site is not loading, it’s down -> https://prnt.sc/jKsDD5zkpQ8E – You need to see what’s going on with your hosting. I also, wonder why do you use gtm as subdomain?

    Kind Regards.

    Thread Starter freddyeee

    (@freddyeee)

    I think that there was some problem with the firewall with one security plugin, I fixed it. could you please check again ?

    For the server side tracking with GTM I need a subdomain, that’s why.

    Hi @freddyeee,

    Your site is still throwing 502 error – https://prnt.sc/y8VUnZUDufmF

    About CORS, it can be defined in the .htaccess file (if your site is on apache web server). If your site is on LiteSpeed or Nginx web server then CORS needs to be added differently.

    You can try this code if your site is running on Apache web server – you need to add it to the .htaccess file of your main domain:

    <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "https://gtm.runayaq.com"
    Header set Access-Control-Allow-Methods "GET, POST, OPTIONS"
    Header set Access-Control-Allow-Headers "X-Requested-With, Content-Type, Accept"
    </IfModule>

    Kind regards.

    Thread Starter freddyeee

    (@freddyeee)

    Thank very much, but I use NGINX cache, what other option do I have without deactivating that cache ?

    Hi @freddyeee,

    You need to find nginx config file on your hosting, and to add a location block:

    location / { # Replace / with your desired location path if needed
    if ($http_origin ~* https://gtm\.runayaq\.com) {
    add_header 'Access-Control-Allow-Origin' "$http_origin";
    add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
    add_header 'Access-Control-Allow-Headers' ?
    'X-Requested-With, Content-Type, ?
    Accept';
    }
    # Your other location configuration goes here...
    }

    Kind Regards.

    Thread Starter freddyeee

    (@freddyeee)

    Thank you very much

    location / { # Replace / with your desired location path if needed

    what should I use for location ? could you please explain a little bit with an example ?

    Thread Starter freddyeee

    (@freddyeee)

    also, my server is apache, but I have NGINX cache, do I have to deactivate that cache with this code ?

    location / { # Replace / with your desired location path if needed
    if ($http_origin ~* https://gtm\.runayaq\.com) {
    add_header 'Access-Control-Allow-Origin' "$http_origin";
    add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
    add_header 'Access-Control-Allow-Headers'
    'X-Requested-With, Content-Type,
    Accept';
    }
    # Your other location configuration goes here...
    }
Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.