0

How do I resolve CORB issue that I get when I run this fetch request? This is my code

fetch('https://miragejs.com', {
  method: 'GET',
  mode: 'no-cors',
  contentType: 'application/json',
  headers: {
    'Access-Control-Allow-Origin': '*'
  }
})
  .then(r => r.json())
  .then(res => {
    console.log(res);
    setData(res);
  });
}, []);

When I run this I get this error -:

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://miragejs.com/ with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.

Can anyone tell me what do I need to do ??

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
Abhisar Tripathi
  • 1,569
  • 10
  • 21
  • CORS/CORB headers are for the *response* from the server, not the request. You can use a server-side proxy to access the target URL, but you cannot get around browser security. – Pointy May 22 '21 at 14:56
  • 1
    **You** can't do anything about it, unless you also run `miragejs.com`. They have to add headers at their end to allow your site to use that content. Alternatively you can make a request to another server you control, and have that server request it from `miragejs.com`. (The goal of the SOP isn't preventing you accessing that content, it's browser user security/privacy.) – T.J. Crowder May 22 '21 at 14:57

0 Answers0