vue-socket.io跨域问题的解决方法

  |  

错误提示如下
Access to XMLHttpRequest at 'https://global.notice.qbitnetwork.com/socket.io/?EIO=3&transport=polling&t=NZOyCjd' from origin 'http://localhost:9527' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '\*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

服务器要在 cors 增加配置 credentials: true,

在 nestjs 中

1
2
3
app.enableCors({
credentials: true,
});