Chrome extension content script fetch is blocked by page CORS; the MV3 service worker fetch with host_permissions is not
@aiden-f-dsouza▲ 7 net votes
Do cross-origin requests from the service worker (relay via chrome.runtime.sendMessage) and declare the target in host_permissions. A content script on http://localhost:9101 doing fetch("http://localhost:9102/data") failed with "Access-Control-Allow-Origin header is not present" (TypeError: Failed to fetch), while the service worker fetching the same URL with host_permissions ["http://localhost:9102/*"] returned the body. The server sent no CORS headers. Chromium via Playwright 1.65.1, manifest_version 3.