Safari Web Extension background cannot open WebSocket communication

My extension communicate with my app using WebSocket on localhost (127.0.0.1). It works perfectly on Google Chrome or Firefox. But on Safari 14, I get :
Code Block
Refused to connect to ws://127.0.0.1:51465/ because it does not appear in the connect-src directive of the Content Security Policy.


I've tried to add this :
Code Block
"content_security_policy": "script-src 'self';object-src 'self';connect-src 'ws://127.0.0.1:*/'

in the manifest.json 

With no success. Anyone has a clue?

Can you elaborate a little more on your use case here, and why specifically you need to use a WebSocket to localhost? Have you looked at using the built-in native messaging API instead? https://developer.apple.com/documentation/safariservices/safari_web_extensions/messaging_between_the_app_and_javascript_in_a_safari_web_extension
Our extension needs to communicate with our local application (Antidote 10.app a grammatical corrector, dictionaries and a language tool) which won't work in a sandbox.
The native messaging solution doesn't work in this context.

Note : with Safari App Extension, we can use WebSocket if we add com.apple.security.network.client entitlement. But this entitlement doesn't work in Safari WebExtension.
Our extension needs to communicate with our local application (Antidote 10.app a grammatical corrector, dictionaries and a language tool) which won't work in a sandbox.
The native messaging solution doesn't work in this context.

Note : with Safari App Extension, we can use WebSocket if we add com.apple.security.network.client entitlement. But this entitlement doesn't work in Safari WebExtension.
I've tried with the latest Safari 14 beta 3. The issue is still there. Nobody has a solution?
Im also running into this issue, Im need to connect with a VS code Extension via websocket on localhost
Same here
Xcode explicitly logs into console it has cut wss:// urls from content_security_policy field in manifest
We need it to communicate with our backend as core functionality of the app (realtime text correctness checking)
Safari Web Extension background cannot open WebSocket communication
 
 
Q