2760
Views
3
Comments
How to Resolve CORS (access-control-allow-origin)?
Question

I have to admit this is not Outsystems specific, but I've always wondered how to resolve this issue even before. 

I intend to use the Youtube IFRAME API, here's my code inside a Development\JS interface:

SyntaxEditor Code Snippet

"
   var tag = document.createElement('script');

      tag.src = 'https://www.youtube.com/watch?v=VIDE_ID';
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

      // 3. This function creates an <iframe> (and YouTube player)
      //    after the API code downloads.
      var player;
      function onYouTubeIframeAPIReady() {
        player = new YT.Player('player', {
          height: '390',
          width: '640',
          events: {
            'onReady': onPlayerReady,
            'onStateChange': onPlayerStateChange
          }
        });
      }
"

ERROR:

"Cross-Origin Read Blocking (CORB) blocked cross-origin response https://www.youtube.com/watch?v=hhZ5feVHy_w with MIME type text/html"


Can I resolve this using plain JS or is this a server-side issue?

2023-02-10 19-42-59
João Melo
 
MVP
2018-01-16 10-48-02
Maria João Portela

Hello,

I am having a similar issue:

I have a landing page in which a news feed from another source is loaded (with a loadOnVisible).

It worked fine, until I added a regular pop in the landing page. 

After that, sometimes, randomly it seems, the content of the pop up gets blocked, complaining about the access control allow origin.

But I find it strange, since the news feed has this setup to allow all (*):

And strangely, it's the pop up (the information comes from the same domain as the app) that gets blocked.

Could it be the order of the load?

I added a header to the pop up (in preparation) with Access cointrol allow origin set to accept all that comes from the news feed domain.

Could this be a platform bug? There are two iframes from diferent sources on the page, but the pop up should not provoque this, right?

This is the error we are getting:

Thank you,

Maria João Portela

UserImage.jpg
Fábio Santos

Hi, i'm facing the same problem on Microsoft Browsers(IE,Edge) did you reach a solution?


Best Regards,

Fábio Santos

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.