Skip to content

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

@wuchuguang

Description

@wuchuguang

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions