wss://ctf.xidian.edu.cn/api/traffic/Ss5MR7DUQJwSxpV-GBGNF
时间: 2023-08-20 13:06:56 浏览: 331
你可以在Vue项目的config.vue文件中添加以下配置信息来解决这个问题:
```
devServer: {
host: '0.0.0.0',
// https: true,
port: 6103,
client: {
webSocketURL: 'wss://ctf.xidian.edu.cn/api/traffic/Ss5MR7DUQJwSxpV-GBGNF/ws',
},
headers: {
'Access-Control-Allow-Origin': '*',
},
},
```
另外,在vue.config.js文件中也可以添加相似的配置代码:
```
devServer: {
host: '0.0.0.0',
port: 3000,
client: {
webSocketURL: 'wss://ctf.xidian.edu.cn/api/traffic/Ss5MR7DUQJwSxpV-GBGNF/ws',
},
headers: {
'Access-Control-Allow-Origin': '*',
},
},
```
这样做可以确保你的Vue项目能够成功连接到wss://ctf.xidian.edu.cn/api/traffic/Ss5MR7DUQJwSxpV-GBGNF。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [vue项目使用websocket时报错: connection to ‘ws://...‘failed: Error in connection establish](https://blog.csdn.net/weixin_65793170/article/details/128127889)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [WebSocket connection to ‘ws://xxx.xxx.x.xxxx:8080/ws‘failed:问题](https://blog.csdn.net/z914020826/article/details/127232233)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [控制台反复输出WebSocket connection to ‘ws://10.133.212.203:8080/ws‘ failed:](https://blog.csdn.net/weixin_46466212/article/details/126762870)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文