Axios throws that the http adapter is not available inside a browser extension
Uncaught (in promise) Error: Error: Adapter 'http' is not available in the buildShort answer
Axios chooses an adapter that fits where it runs: xhr in a browser, http in Node.js, fetch elsewhere. A Manifest V3 extension service worker cannot call XMLHttpRequest, so the xhr route is gone, and a forced http adapter does not exist in a bundle. Tell axios to use the fetch adapter, or call fetch directly.
Fix it fast
1Find out which cause you have
Find out where the failing request runs and whether any code sets the adapter option, in a config file or an interceptor.
grep -rn "adapter" src/ background/ 2>/dev/null2Match what you see, then jump to its fix
- 1
The call is made from the background service worker of the extension, not from a popup or pageThe request runs in a Manifest V3 service worker, where XMLHttpRequest cannot be calledFix - 2
A shared axios config file sets adapter to 'http', copied from server codeA config forces adapter: 'http' and the bundler targets the browserFix
- 1
What does the error look like?
Uncaught (in promise) Error: Error: Adapter 'http' is not available in the build
Cause 1 of 2
The request runs in a Manifest V3 service worker, where XMLHttpRequest cannot be called
1Check
Chrome's extension documentation says XMLHttpRequest cannot be called from a service worker and tells you to use fetch instead. Axios lists its adapters as xhr, http and fetch, and picks the first one the environment supports.
grep -n "service_worker" manifest.json2Fix
Select the fetch adapter for the axios instance used in the service worker.
import axios from 'axios';
const api = axios.create({ adapter: 'fetch' });
const { data } = await api.get('https://api.example.com/items');3Verify
Reload the extension, trigger the request from the service worker and watch the console for the error.
# chrome://extensions > your extension > service worker > InspectConfirmed by developer.chrome.com
Cause 2 of 2
A config forces adapter: 'http' and the bundler targets the browser
1Check
Axios documents the adapter option as a name or an ordered array, and says the http adapter is the one used in Node.js. Code bundled for an extension does not run in Node.js, so a forced http adapter is not what axios can use there.
grep -rn "adapter:" src/ | grep -i http2Fix
Remove the forced adapter so axios can choose, or give an ordered list that starts with fetch.
const api = axios.create({
adapter: ['fetch', 'xhr'],
});3Verify
Build the extension again and repeat the request.
npm run buildConfirmed by axios.rest
How do I stop it coming back?
- Keep one axios instance per runtime (service worker, page, Node.js) instead of one shared config.
- In a service worker, call fetch or use the fetch adapter; do not use XMLHttpRequest-based libraries.
- Do not copy server-side axios settings into browser or extension code.
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.
Related fixes
Web apps
tsconfig rejects allowImportingTsExtensions
An error that allowImportingTsExtensions needs noEmit or emitDeclarationOnly
allowImportingTsExtensions lets files import each other with .ts or .tsx extensions, and TypeScript only allows it together with noEmit or emitDeclarationOnly.
2 causes, each with a fixWeb apps
AuthUserPoolException: Auth UserPool not configured in a Next.js app
Auth UserPool not configured
The error means an Amplify Auth call ran before Amplify.configure did.
3 causes, each with a fixWeb apps
Module not found for antd/dist/antd.less after upgrading to Ant Design 5
Module not found: Error: Can't resolve 'antd/dist/antd.less'
Ant Design 5 dropped Less and the bundled CSS file for CSS-in-JS, so antd/dist/antd.less no longer exists.
3 causes, each with a fixWeb apps
Apollo Server rejects a request as a potential CSRF
HTTP 400 Bad Request from the GraphQL endpoint
Apollo Server's CSRF prevention is on by default.
3 causes, each with a fixWeb apps
Apollo Client is blocked by CORS when the GraphQL server runs on AWS Lambda
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Apollo Server does not set CORS for you when it runs behind a framework or integration, and on Lambda that layer is API Gateway.
5 causes, each with a fixWeb apps
A POST to a Google Apps Script web app returns 405 or a CORS error
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Apps Script web apps run doPost for POST and doGet for GET, and the Apps Script guides describe no other entry points.
3 causes, each with a fix