Skip to content

Crash after websocket connection is made #1062

Description

@brambora69123

Checks

Describe the bug (be clear and concise)

When I attempt to connect to a proxied websocket, it crashes

The error:

TypeError: undefined is not an object (evaluating 'server.on')
      at C:\projects\Nova\services\Nova.Backend\node_modules\http-proxy-middleware\dist\http-proxy-middleware.js:56:17
      at C:\projects\Nova\services\Nova.Backend\node_modules\http-proxy-middleware\dist\http-proxy-middleware.js:50:22

Step-by-step reproduction instructions

1. Add a proxy middleware with ws set to true
2. Make a request to a websocket
3. Crash

Expected behavior (be clear and concise)

It should not crash upon a websocket request

How is http-proxy-middleware used in your project?

const frontendProxyMiddleware = createProxyMiddleware({
    target: "http://localhost:3000",
    changeOrigin: true,
    ws: true,
});

app.use(
    frontendProxyMiddleware
);

What http-proxy-middleware configuration are you using?

{
    target: "http://localhost:3000",
    changeOrigin: true,
    ws: true,
}

What OS/version and node/version are you seeing the problem?

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 AMD Ryzen 7 7700X 8-Core Processor
    Memory: 15.11 GB / 31.15 GB
  Binaries:
    Node: 22.12.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.9.0 - C:\Program Files\nodejs\npm.CMD
    bun: 1.1.42 - ~\.bun\bin\bun.EXE
  Utilities:
    Git: 2.47.1.
    Curl: 8.10.1 - C:\WINDOWS\system32\curl.EXE
  IDEs:
    VSCode: 1.96.2 - C:\Users\Nicolas\AppData\Local\Programs\Microsoft VS Code\bin\code.CMD
    Visual Studio: 17.12.35527.113 (Visual Studio Community 2022)
  Languages:
    Java: 21.0.5
  Browsers:
    Edge: Chromium (131.0.2903.112)

Additional context (optional)

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions