http-proxy-middleware
http-proxy-middleware copied to clipboard
Https (wss) error Invalid frame header
Expected behavior
Actual behavior
Setup
- http-proxy-middleware: _version_0.18.0
- server: express_version_4.16.0
- other relevant modules
proxy middleware configuration
var wsProxy = proxyMiddleware('ws://localhost:1337/socket.io', {
changeOrigin:true,
secure: false,
protocolRewrite: 'http'
});```
#### server mounting
```javascript
var app = express();
app.use(wsProxy );
var server = https.createServer({
key: privateKey,
cert: certificate,
passphrase: 'splus'
}, app).listen(8443);
const WebSocket = require('ws')
const wss = new WebSocket.Server({ server });
server.on('upgrade', wsProxy2.upgrade);
What can I do to make it work!
what is the error that you're getting?
index.js:1 WebSocket connection to 'ws://xenui.ctest2.0su.kr/api/' failed: Invalid frame header
(anonymous) @ index.js:1
index.js:1 Uncaught Error: Unhandled "error" event. ([object Event])
at t.i.emit (index.js:1)
at WebSocket.
Same issue. Any luck resolving it?
{
devServer: {
headers: { "Access-Control-Allow-Origin": "*" },
hot: true,
compress: false,
historyApiFallback: true,
allowedHosts: "all",
devMiddleware: {
publicPath: "/",
stats: {
colors: true,
}
},
static: {
directory: path.join(__dirname, 'dist'),
publicPath: "/"
},
client: {
logging: "verbose",
progress: true
},
host: options.host || "0.0.0.0", // makes server available to all hosts, not just localhost
port: options.port || 8080,
proxy: {
"/ws": {
target: "ws://localhost:5000",
logLevel: "debug", // debug
secure: false,
ws: true,
changeOrigin: true
}
},
}
}