title: WebSockets in Create React App with Webpack proxy
body: <p>I created my React app using Create React App in version 3.1.2 (19 Sept 2019). I was trying to configure proxy for Web Socket requests, but it seems that when I am using the proxy, the connection is not established. I have used <a href="https://github.com/Ibro/AspNetCoreSignalR_React" rel="noreferrer">THIS</a> example to set up my things. The server is Asp.Net Core as in example and it works as long as it has the address wired into the initalization. This snippet works:</p>
  
  <pre><code>const hubConnection = new HubConnectionBuilder()
    .withUrl("https://localhost:44392/chatHub")
    .build();
  </code></pre>
  
  <p>And this doesn't:</p>
  
  <pre><code>const hubConnection = new HubConnectionBuilder()
    .withUrl("chatHub")
    .build();
  </code></pre>
  
  <p>With this:</p>
  
  <pre><code>{
    "proxy": "https://localhost:44392/",
    "name": "my-app",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
      "@microsoft/signalr": "^3.0.0",
      "react": "^16.9.0",
      "react-dom": "^16.9.0",
      "react-scripts": "3.1.2"
    },
  (...)
  </code></pre>
  
  <p>I saw a suggestion <a href="https://cli.vuejs.org/config/#devserver-proxy" rel="noreferrer">HERE</a> that I might use an object in proxy setup, but when I tried I got an error that proxy address has to be a single string, not an object:</p>
  
  <pre><code> proxy: {
        '^/api': {
          target: '&lt;url&gt;',
          ws: true,
          changeOrigin: true
        },
        '^/foo': {
          target: '&lt;other_url&gt;'
        }
  </code></pre>