I am currently working on an extension which needs to be available for chrome and safari. The extension works fine in chrome but when testing the compatibility with safari I get an error when fetching data within the content scripts. Currently I send a message from the content script to the background script in order for the background script to create the fetch request. When sending the fetch request I get two errors:
- Fetch API cannot load https://apiurl due to access control checks
- Failed to load resource: Origin safari-web-extension://id is not allowed by Access-Control-Allow-Origin. Status code: 204
This error only occurs when the fetch requests are triggered by the content script and not when creating the fetch requests from the extension popup.
I am confused as the requests should be made from the same location, the background script but it works with the popup but not the content scripts. I have tried disabling cross-origin restrictions, local file restrictions and turning off other extensions but that has not worked. Do I need to change the response on the server side, safari settings or is my method wrong?
Edit: Seems to be I have the same issue as CORS issue during HTTP request from background service worker in Safari web extension with the same workaround