Post

Replies

Boosts

Views

Activity

Reply to Safari Web Extension background request CORS issues
I am currently having the issue in Manifest v3 (In Manifest v2 everything works fine) In my manifest I have this: "host_permissions": [ "*://example.com/*" ] When I do fetch("https://example.com") in background.js I get these errors: [Error] Fetch API cannot load https://example.com/ due to access control checks. [Error] Failed to load resource: Origin safari-web-extension://e0b5d7c7-c079-484b-8825-44d261383cb6 is not allowed by Access-Control-Allow-Origin. Status code: 200 (example.com, line 0) Is there a way to avoid CORS issues without altering server access control settings? My Stackoverflow questions: https://stackoverflow.com/questions/73712933/cors-issue-during-http-request-from-background-service-worker-in-safari-web-exte Link to GitHub repo with the project to reproduce the issue: https://github.com/nick-kadutskyi/safari-ext-cors-issue Additional link to download project files to reproduce the issue: https://web.tresorit.com/l/DKcJu#83UK96xDiX0g9P35gehUsw To test the issue: Allow Unsighned Extensions in Safari > Develop menu item Run the project in Xcode Once extension is installed open console for background page Develop → Web Extension Background Pages → Test CORS Issue Extension - Service Worker In main window navigate to https://example.com (you will need to allow the extension to access this domain via action button) or click action button in a toolbar (both actions will trigger fetch function in background script) Update 1: The workaround for now to use background scripts (deprecated in Manifest v3) instead of background service worker. Instead of this: "background": { "service_worker": "background.js" }, Do this: "background": { "scripts": ["background.js"] },
Sep ’22