Socket io CORS blocked

后端 未结 2 1465
死守一世寂寞
死守一世寂寞 2021-01-27 05:53

i got this warning when using https domain and https socket io.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at htt         


        
2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-27 06:11

    use this code its work.

    app.use(
      cors({
        origin: 'http://localhost:3000', // allow to server to accept request from different origin
        methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
        credentials: true // allow session cookie from browser to pass through
      })
    );
    

提交回复
热议问题