9

It's perfectly working for Http, but not for WebSocket. I did not find the documentation about this. How can I do proxy for WS?

ng serve --proxy-config proxy.conf.json

proxy.conf.json:

{
  "/": {
    "target": "http://localhost:8080",
    "secure": false
  }
}
2
  • 1
    have you tried using ws:// instead of http://? Commented Apr 25, 2017 at 20:25
  • 1
    Yes, I tried. It also does not work. Commented Apr 25, 2017 at 20:53

1 Answer 1

12

Angular cli uses http-proxy-middleware for proxy under the hood. take a look at the documentation: https://github.com/chimurai/http-proxy-middleware

there is a websocket ws boolean option you can use as described in this section: https://github.com/chimurai/http-proxy-middleware#http-proxy-options

so you can change your config to:

{
  "/": {
    "target": "http://localhost:8080",
    "secure": false,
    "ws":true
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.