Vue 启动后控制台不停的报错:WebSocket connection to ‘ws://localhost:8080/api/handler‘ failed: Invalid frame head
0x00 问题描述
有点崩溃了,vue3怎么问题这么多!启动npm run serve
后,发现前端控制台不断的报错:
WebSocket connection to ‘ws://localhost:8080/api/handler‘ failed: Invalid frame header
WebSocket connection to ‘ws://localhost:8080/api/handler‘ failed: Invalid frame header
WebSocket connection to ‘ws://localhost:8080/api/handler‘ failed: Invalid frame header
WebSocket connection to ‘ws://localhost:8080/api/handler‘ failed: Invalid frame header
...
0x01 解决方案
解决方式是修改vue.config.js
代理中的ws:true
改为false
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
lintOnSave: false,
devServer: {
https: false,
hot: 'only',
proxy: {
'/': {
target: 'http://192.168.99.100:8001',
changeOrigin: true,
ws: false // 修改这里
}
}
}
})
0x02 参考文章
https://www.codeleading.com/article/82676127135/