前后端分离 websocket 的应用 / springboot + vue + websocket + wss
vue.config.js
proxy: {
"/ws": {
target: `http://localhost:8080/websocket/`,
ws: true,
changeOrigin: true,
pathRewrite: {
"/ws": ""
}
}
}
new WebSocket
let new_url = getWsLocation("ws/20");
console.log(new_url);
let socket = new WebSocket(
// "ws://localhost:5000/ws/20"
new_url
);
- nginx 中配置wss反向代理的方法