koa-socket icon indicating copy to clipboard operation
koa-socket copied to clipboard

how to use new WebSocket("ws://xxxxx:xx") connection this koa-socket

Open wuchuguang opened this issue 9 years ago • 1 comments

in chrome brower , I use : `

var g = new WebSocket("ws://localhost:3000");
VM309:1 Refused to connect to 'ws://localhost:3000/' because it violates the following Content Security Policy directive: "connect-src 'self' uploads.github.com status.github.com collector.githubapp.com api.github.com www.google-analytics.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com wss://live.github.com".

(anonymous) @ VM309:1
VM309:1 Uncaught DOMException: Failed to construct 'WebSocket': Refused to connect to 'ws://localhost:3000/' because it violates the document's Content Security Policy.
    at <anonymous>:1:9
(anonymous) @ VM309:1

`

import IO from 'koa-socket';
const io = new IO();
module.exports = function(app){
    console.log(`websocket start...`);
    io.attach( app );
    io.on( 'join', ( ctx, data ) => {
        console.log( 'join event fired', data )
    })
};

//app is my koa server . listen:3000

wuchuguang avatar Jun 05 '17 02:06 wuchuguang

@wuchuguang don't use tab with github open to make such requests ;)

mateoKaradza avatar Oct 20 '17 10:10 mateoKaradza