Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cors options to get Gists

I tried to embed my gist with github script. I have a NodeJS ExpressJS app, create a static page and paste script tag that was generated by github.gist. And now i got an error:

my-website:35 Cross-Origin Read Blocking (CORB) blocked cross-origin response https://gist.github.com/PinkyRabbit/7f2db625ae53d799b5ecc4b710c65644 with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.

I tried to allow cors with the cors module, but even if I use default setting to open cors for all domains cors() - nothing changed, github.gists still blocked.

like image 623
Mikita Melnikau Avatar asked Dec 06 '25 06:12

Mikita Melnikau


1 Answers

I encountered this same problem and my solution was replacing the initial content of the iframe tag

data:text/html;charset=utf-8,
<head>
  <base target='_blank' />
</head>
<body>
  <script src='${this.gist_link}'><\/script>
</body>

With:

data:text/html;charset=utf-8,
<head>
  <base target='_blank' />
</head>
<body>
  <script src='${this.gist_link}.js'><\/script>
</body>

The difference being the ".js" at the end of the gist link so github can send the specific resource type that was requested

like image 164
Leslie Douglas Avatar answered Dec 07 '25 21:12

Leslie Douglas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!