Is it possible to proxy websocket connections within the webpack dev server? I know how to proxy regular HTTP requests to another backend but it's not working for websockets, presumably because the target in the proxy configuration starts with http://...
1) webpack-dev-server can only proxy websocket connections, nothing more. 2) There is no requirement that you should split your server into a HTTP and WS parts. To use both in javascript you can use express-ws. This is also available in other languages (Spring supports it, Django also).
WebSocket over a Forward Proxy. WebSocket communication can take successfully take place in the presence of forward proxies, providing the client and proxy server have been configured properly to deal with it.
Today, most transparent proxy servers will not yet be familiar with the Web Socket protocol and these proxy servers will be unable to support the Web Socket protocol. In the future, however, proxy servers will likely become Web Sockets-aware and able to properly handle and forward WebSocket traffic.
webpack-dev-server can proxy some requests to others servers. This might be useful for developing API client when you want to send requests to same domain. Proxy is configured via proxy parameter.
Version 1.15.0 of the webpack-dev-server supports proxying websocket connections. Add the following to your configuration:
devServer: { proxy: { '/api': { target: 'ws://[address]:[port]', ws: true }, }, }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With