So, I'm using ws package for my backend, and this is my server that I copied from getting started page:
import { WebSocketServer } from 'ws' const wss = new WebSocketServer({ port: 8080 }) wss.on('connection', function connection(ws) { ws.on('message', function message(data) { console.log('received: %s', data) }) ws.send('something') }) Now, in my browser console I run this :
const socket = new WebSocket("ws://localhost:8080") I get an error:
Content Security Policy: The page’s settings blocked the loading of a resource at ws://localhost:8080/ (“connect-src”).
I've done some googling, and it seems like the connection should be secure in order it to work? However, MDN and other sources do not mention it anywhere. Am I doing something wrong? I'd appreciate any help.
ws://localhost:8080. Perhaps CORS?