A React app cannot load an API response: blocked by ORB
net::ERR_BLOCKED_BY_ORBShort answer
ORB blocks a cross-origin response when the request ran in no-cors mode and the body does not look like something that mode is allowed to load, such as JSON. Remove mode no-cors, let the server send CORS headers, and make sure it returns a Content-Type that matches the body.
Fix it fast
1Find out which cause you have
Open DevTools, go to Network, click the blocked request and check the Content-Type response header. In the console, log the Response to see if its type is opaque.
const res = await fetch(url, { mode: "no-cors" }); console.log(res.type, res.status); // "opaque" 0 means no-cors is in play2Match what you see, then jump to its fix
- 1
res.type is 'opaque', status is 0, body is nullThe request uses mode: 'no-cors' for data you want to readFix - 2
The blocked response has content-type application/json or text/html and nosniff in its headersThe server sends X-Content-Type-Options: nosniff with a JSON or HTML type on a no-cors requestFix - 3
An image, script or stylesheet is blocked and its content-type is wrong or genericThe Content-Type header does not match the fileFix
- 1
What does the error look like?
net::ERR_BLOCKED_BY_ORBblocked by orbResponse status 0 and an empty body in fetch
Cause 1 of 3
The request uses mode: 'no-cors' for data you want to read
1Check
Search your code for a fetch call or a library option that sets no-cors. That mode makes the request succeed without CORS headers but hides the result from your script.
grep -rn "no-cors" src/2Fix
Delete the no-cors option so fetch uses the default cors mode, then allow your page's origin on the API server with an Access-Control-Allow-Origin header.
const res = await fetch("https://api.example.com/posts");
const posts = await res.json();3Verify
The response type is cors and the JSON parses.
console.log(res.type); // "cors"Confirmed by developer.mozilla.org
Cause 2 of 3
The server sends X-Content-Type-Options: nosniff with a JSON or HTML type on a no-cors request
1Check
ORB blocks HTML, JSON and XML responses on no-cors requests when nosniff is set. Look at the response headers of the blocked request.
curl -s -D - -o /dev/null https://api.example.com/posts2Fix
Do not load a data endpoint through a no-cors path such as an img or script tag or a no-cors fetch. Call it with fetch in cors mode instead.
// not: <script src="https://api.example.com/posts">
const posts = await fetch("https://api.example.com/posts").then(r => r.json());3Verify
The request now appears in the Network tab as a normal 200 with readable data.
curl -I -H "Origin: https://app.example.com" https://api.example.com/postsConfirmed by github.com
Cause 3 of 3
The Content-Type header does not match the file
1Check
ORB decides from the declared MIME type, then from the first bytes. A response labelled with an audio, image or video type that is not actually that kind, or an error page served with status 404 on an image URL, is blocked.
curl -s -D - -o /dev/null https://cdn.example.com/hero.png2Fix
Serve each resource with an accurate Content-Type and a 2xx status, and fix the URL if it returns an error page.
# example response headers for a PNG
Content-Type: image/png3Verify
The headers show the right type and a 200 status.
curl -s -D - -o /dev/null https://cdn.example.com/hero.pngConfirmed by github.com
How do I stop it coming back?
- Treat no-cors as a way to send a request, never as a way to read data.
- Give every API route a correct Content-Type and set CORS headers for the origins that need them.
- Check new cross-origin calls in the Network tab before wiring them into components.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Web apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
AxiosError Network Error with code ERR_NETWORK in a React app
Network Error
ERR_NETWORK means the request produced no readable response.
4 causes, each with a fixWeb apps
Axios get works with a URL string but ignores the object passed as the second argument
The server log shows a GET with no query string
axios.get takes a URL and an optional config object.
3 causes, each with a fixWeb apps
Can't resolve '../axios' in a React project
Module not found: Error: Can't resolve '../axios'
A path that starts with ./ or ../ is a file path, not the axios package.
3 causes, each with a fixWeb apps
Axios returns 401 from a React app but the login works elsewhere
Error: Request failed with status code 401
A 401 means the server received the request without valid credentials.
3 causes, each with a fixWeb apps
An axios call never finishes when the API server stops answering
code: 'ECONNABORTED'
Axios has no timeout unless you give it one: the default is 0, which means wait forever.
3 causes, each with a fix