javascriptjsfiddlehtmxcross-origin-read-blocking

CORB: Cross-Origin Read Blocking on JSFiddle


I added https://unpkg.com/htmx.org@1.3.3/dist/htmx.min.js.gz to my jsfiddle, but now I get:

CORB: Cross-Origin Read Blocking

js-fiddle-cors

Is there a way to work around this?

JSFiddle: https://jsfiddle.net/thomas_guettler/7cLy8m5u/3/

Code:

<button 
hx-get="https://raw.githubusercontent.com/guettli/html-fragments/main/fragments/simple-div.html">

 Press me
</button>

If I use this URL: https://unpkg.com/htmx.org@1.3.3/dist/htmx.min.js

then I get

Access to XMLHttpRequest at 'https://raw.githubusercontent.com/guettli/html-fragments/main/fragments/simple-div.html' from origin 'https://fiddle.jshell.net' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.


Solution

  • I found a work-around.

    If I use a mocky endpoint, then it works.

    For example: https://run.mocky.io/v3/6f4b9b4c-4ac9-44e0-89fa-da7d222346df

    I guess this http header in the response of github makes the browser reject the snippet:

    Referrer Policy: strict-origin-when-cross-origin