Using HTML5 Fetch API : CORS errors


Hi !

I try to test a little sample code using fetch and I can’t make it work due to CORS errors. The file I request is a simple html piece of code I’d like to insert in my page. On a local server it works well.

fetch('content.html').then(function(response) {  

var sandbox = document.getElementById('sandbox');

    sandbox.innerHTML = resolvedResponse;

}, function(error){

console.log('fetch error : ' + error);


Here is the error : Cross-Origin
Request Blocked: The Same Origin Policy disallows reading the remote
resource at
(Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

I’ve tried to change the mode (same-origin, cors, no-cors), no changes.



Typically you have to address acceptable URL domains in your service configuration whether it be Express, Web API, WCF or other. Look to your API code and setting headers.


It seems indeed an issue with the way Cloud9 proxies requests, not sure if they could clarify what are the settings for, because they seem to block and redirect this type of requests:

Fetch API cannot load Redirect from '' to '' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.


This seems to be solved as from yesterday at least in my experience.


Hmm, still getting the same error. Mine is for Swagger-UI v3, which uses Fetch (v2 doesn’t have this problem).