• The APS Catalog has been deprecated and removed from all Plesk Obsidian versions.
    Applications already installed from the APS Catalog will continue working. However, Plesk will no longer provide support for APS applications.
  • Please be aware: with the Plesk Obsidian 18.0.78 release, the support for the ngx_pagespeed.so module will be deprecated and removed from the sw-nginx package.

Issue Access-Control-Allow-Origin header Missing

djchinezu2

New Pleskian
I have included this javascript on other domains:
PHP:
var id = "<?php echo check_input($_GET['token']); ?>";
    var querystring = "";
    var lockerurl = "https:\/\/www.example.com\/contentlocker\/getlocker.php?" + 'id=' + encodeURIComponent(id) + '&r=' + encodeURIComponent(referrer) + querystring;


    var iframecontents;
    var old_display;

    function optionstoquery(options) {

        var query = "";

        if (options.mt) query += "&mt=" + encodeURIComponent(options.mt);
        if (options.dt) query += "&dt=" + encodeURIComponent(options.dt);
        if (options.dd) query += "&dd=" + encodeURIComponent(options.dd);
        if (options.md) query += "&md=" + encodeURIComponent(options.md);

        return query;

    }

    function og_load(options) {

        if (options) lockerurl += optionstoquery(options);

                        //preload
            var xhr = new XMLHttpRequest();
            xhr.open('GET', lockerurl, true);
            xhr.onreadystatechange = function() {
                if (this.readyState!==4) return;
                if (this.status!==200) {
                    iframecontents = false;
                    return;
                }

                iframecontents = this.responseText;
            };
            xhr.send();

            ogEditBody();
                }

In console of browser I have this error:

Code:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.example.com/contentlocker/getlocker.php?id=3e066b64a78214a17620b5521b6d3ec4&r=aHR0cDovL2NwYWh1Yi51cy9yb29zdGVyMi5odG1s. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

getlocker.php contains some php and html code!

I using

and I have tried by adding in getlocker.php:

Code:
header('Access-Control-Allow-Origin: *');
But still not working!

Any idea? Thank you!
 
Try the following in a .htaccess file;

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