'Running React WebDevServer from .NET core SPA services cause websocket errors

I've created a react project with react scripts.
When started directly with "npm run start", it listens by default to port: 3000.

Since I am running .NET Core Project as a backend server, I use the spa services to establish proxy like this:

app.UseSpa(spa =>
   {
       // To learn more about options for serving an Angular SPA from ASP.NET Core,
       // see https://go.microsoft.com/fwlink/?linkid=864501

       spa.Options.SourcePath = "../ClientApp";

       if (env.IsDevelopment())
       {
           spa.UseProxyToSpaDevelopmentServer("http://localhost:3000");
       }
    });

For hot reload, the client expects a websocket connection to the webdevserver, so it throws many errors like this:

WebSocketClient.js:16 WebSocket connection to 'wss://localhost:3000/ws' failed:

How to disable this hot reload for browser? or redirect websockets connection in the proxy?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source