Skip to content

Conversation

@eps1lon
Copy link
Member

@eps1lon eps1lon commented Nov 19, 2025

Follow-up to #80260

We used to match against the parsedUrl which is the URL after proxy applied. For our default implementation, rewrites won't matter so we use the original request URL instead. Otherwise we'd serve 404s.

This doesn't affect custom implementations of the /.well-known/appspecific/com.chrome.devtools.json route. Only Next.js' default implementation.


if (opts.dev && isChromeDevtoolsWorkspaceUrl(parsedUrl)) {
// We want the original pathname without any basePath or proxy rewrites.
if (opts.dev && isChromeDevtoolsWorkspaceUrl(req.url)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (opts.dev && isChromeDevtoolsWorkspaceUrl(req.url)) {
if (opts.dev && isChromeDevtoolsWorkspaceUrl((req.url || '').split('?')[0])) {

The req.url parameter can include query strings (e.g., ?.foo=bar), but the isChromeDevtoolsWorkspaceUrl function performs a strict equality check that will fail if query parameters are present.

View Details

Analysis

Chrome DevTools URL detection fails with query parameters

What fails: isChromeDevtoolsWorkspaceUrl() function in packages/next/src/server/lib/router-server.ts line 579 performs a strict equality check, but receives the full req.url which includes query parameters. Requests to /.well-known/appspecific/com.chrome.devtools.json?foo=bar fail to match and Chrome DevTools workspace is not recognized.

How to reproduce:

// Current behavior at line 579:
if (opts.dev && isChromeDevtoolsWorkspaceUrl(req.url)) { // req.url may include query string

Send HTTP request: GET /.well-known/appspecific/com.chrome.devtools.json?foo=bar

Result: Request is not recognized as Chrome DevTools workspace endpoint. Handler returns 404 instead of Chrome DevTools JSON response.

Expected: Should recognize the endpoint and return Chrome DevTools workspace configuration, matching requests with or without query parameters (same behavior as line 193 of the same file which explicitly splits req.url on ?).

Reference: The same file at line 193 explicitly handles this case: const urlParts = (req.url || '').split('?', 1) because Node.js req.url includes query strings. The Node.js HTTP documentation confirms req.url includes the query string.

Fix applied: Extract pathname before passing to function at line 579: isChromeDevtoolsWorkspaceUrl((req.url || '').split('?')[0])

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chrome doesn't include query params in its requests

@ijjk
Copy link
Member

ijjk commented Nov 19, 2025

Failing test suites

Commit: 15e692f | About building and testing Next.js

pnpm test-start test/e2e/chrome-devtools-workspace/chrome-devtools-workspace.test.ts (job)

  • chrome-devtools-workspace proxy > should be able to connect to Chrome DevTools in dev (DD)
Expand output

● chrome-devtools-workspace proxy › should be able to connect to Chrome DevTools in dev

next build failed with code/signal 1

  75 |             if (code || signal)
  76 |               reject(
> 77 |                 new Error(
     |                 ^
  78 |                   `next build failed with code/signal ${code || signal}`
  79 |                 )
  80 |               )

  at ChildProcess.<anonymous> (lib/next-modes/next-start.ts:77:17)

@eps1lon eps1lon force-pushed the sebbie/11-19-_devtools_ensure_chrome_devtools_workspace_can_connect_with_proxy_rewrites branch from 15e692f to ccefd9e Compare November 19, 2025 13:09
@eps1lon eps1lon marked this pull request as ready for review November 19, 2025 17:00
@eps1lon eps1lon merged commit a7b0b5f into canary Nov 19, 2025
407 of 413 checks passed
@eps1lon eps1lon deleted the sebbie/11-19-_devtools_ensure_chrome_devtools_workspace_can_connect_with_proxy_rewrites branch November 19, 2025 18:47
Moroshima pushed a commit to Moroshima/next.js that referenced this pull request Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants