Skip to content

v8 does not respect req.url #2303

@Methuselah96

Description

@Methuselah96

Have you used AI?

No

Bug Description

In v8 of webpack-dev-middleware, the middleware is trying to serve req.originalUrl when it should be trying to serve req.url. This is happening because of this logic. This breaks usage when used with URL rewrites, which is common with middleware like connect-history-api-fallback.

Link to Minimal Reproduction and step to reproduce

https://github.com/Methuselah96/webpack-dev-middleware-rewrite

Steps:

  1. Run npm install
  2. Run npm run watch
  3. Navigate to http://localhost:3000/some-path
  4. Observe "Cannot GET /some-path" error

Expected Behavior

The dev middleware should respect the req.url and serve /index.html instead of returning an error

Actual Behavior

The dev middleware tries to load /some-path and fails

Environment

System:
    OS: Windows 11 10.0.26200
    CPU: (20) x64 13th Gen Intel(R) Core(TM) i5-13500
    Memory: 7.01 GB / 31.65 GB
  Binaries:
    Node: 24.11.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 4.9.2 - C:\Program Files\nodejs\yarn.CMD
    npm: 11.6.1 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.15.9 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Chrome: 146.0.7680.165
    Edge: Chromium (140.0.3485.54)
    Firefox: 149.0 - C:\Program Files\Mozilla Firefox\firefox.exe
    Internet Explorer: 11.0.26100.8115
  Packages:
    html-webpack-plugin: ^5.6.6 => 5.6.6 
    webpack: ^5.105.4 => 5.105.4 
    webpack-cli: ^7.0.2 => 7.0.2 
    webpack-dev-middleware: ^8.0.2 => 8.0.2

Is this a regression?

Yes (please specify version below)

Last Working Version

v7.4.5

Additional Context

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions