I am writing a plugin for Chrome (manifest v3). It should create a WebSocket connection between the Service Worker and the Chrome Debugger, so that I can control a page with puppeteer.
const browserDebugger = await (
await fetch(http://localhost:9223/json/version, { mode: "no-cors" })
).json();
const debuggerURL = browserDebugger.webSocketDebuggerUrl;
const chromeWebsocket = new WebSocket(debuggerURL);
I am getting the following error in the last line:
WebSocket connection to 'ws://localhost:9223/devtools/browser/2cd7eac1-a1e0-41ed-9eac-8ba8d0befc9e' failed: Error during WebSocket handshake: Unexpected response code: 403
manifest.json:
{
"manifest_version": 3,
....
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'; connect-src http://localhost:9223/ ws://localhost:9223/ http://localhost:4821/ ws://localhost:4821/"
},
"host_permissions": [
"http://*/*",
"https://*/*",
"http://localhost:4821/",
"http://localhost:9223/"
],
"permissions": [
"debugger",
"tabs",
]
}
What is wrong?