Configuring the websocket proxy interface address in vue-cli does not work

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.


var ws = new WebSocket ('ws://' + location.host +' / socket/xxx')


the proxy is set like the landlord, but when using var ws = new WebSocket ('ws://' + location.host +' / socket/xxx'), there is always an error
WebSocket connection to 'ws://xxx.xxx.xxx.xxx/socket/xxx' failed: Connection closed before receiving a handshake response.
does the landlord know how to solve the problem?


I have the same question. Which god will give us some advice

?
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e54326-452a5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e54326-452a5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?