configuration file:
dev: {
env: require("./dev.env"),
port: 8080,
autoOpenBrowser: true,
assetsSubDirectory: "static",
assetsPublicPath: "/",
proxyTable: {
"/risk":{
target:"http://xxx.xxx.xxx.xxx/"
},
"/socket": {
target:"ws://xxx.xxx.xxx.xxx/",
ws: true,
}
}
var ws = new WebSocket ("/ socket/xxx")
there is no problem directly using var ws = new WebSocket ("ws://xxx.xxx.xxx.xxx/socket/xxx"). When configuring the proxy address, the interface in the" / risk" path is normal, and the / socket interface reports an error
Uncaught DOMException: Failed to construct "WebSocket": The URL" / socket/xxx" is invalid.