Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
a7b0b5fa
Unverified
Commit
a7b0b5fa
authored
Nov 19, 2025
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Nov 19, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[devtools] Ensure Chrome DevTools workspace can connect with proxy rewrites (#86289)
parent
70cdb3c5
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
4 deletions
+68
-4
chrome-devtools-workspace.ts
packages/next/src/server/lib/chrome-devtools-workspace.ts
+2
-3
router-server.ts
packages/next/src/server/lib/router-server.ts
+2
-1
chrome-devtools-workspace.test.ts
...rome-devtools-workspace/chrome-devtools-workspace.test.ts
+30
-0
page.js
...rome-devtools-workspace/fixtures/proxy/app/[lang]/page.js
+4
-0
layout.js
...2e/chrome-devtools-workspace/fixtures/proxy/app/layout.js
+11
-0
next.config.js
...e/chrome-devtools-workspace/fixtures/proxy/next.config.js
+6
-0
proxy.js
test/e2e/chrome-devtools-workspace/fixtures/proxy/proxy.js
+13
-0
No files found.
packages/next/src/server/lib/chrome-devtools-workspace.ts
View file @
a7b0b5fa
import
type
{
ServerResponse
}
from
'http'
import
type
{
NextConfigComplete
}
from
'../config-shared'
import
type
{
NextUrlWithParsedQuery
}
from
'../request-meta'
import
{
randomUUID
}
from
'crypto'
import
*
as
fs
from
'fs'
...
...
@@ -11,9 +10,9 @@ import { getStorageDirectory } from '../cache-dir'
let
workspaceUUID
:
string
|
null
=
null
export
function
isChromeDevtoolsWorkspaceUrl
(
url
:
NextUrlWithParsedQuery
pathname
:
string
|
undefined
):
boolean
{
return
url
.
pathname
===
'/.well-known/appspecific/com.chrome.devtools.json'
return
pathname
===
'/.well-known/appspecific/com.chrome.devtools.json'
}
export
async
function
handleChromeDevtoolsWorkspaceRequest
(
...
...
packages/next/src/server/lib/router-server.ts
View file @
a7b0b5fa
...
...
@@ -575,7 +575,8 @@ export async function initialize(opts: {
)
}
if
(
opts
.
dev
&&
isChromeDevtoolsWorkspaceUrl
(
parsedUrl
))
{
// We want the original pathname without any basePath or proxy rewrites.
if
(
opts
.
dev
&&
isChromeDevtoolsWorkspaceUrl
(
req
.
url
))
{
await
handleChromeDevtoolsWorkspaceRequest
(
res
,
opts
,
config
)
return
}
...
...
test/e2e/chrome-devtools-workspace/chrome-devtools-workspace.test.ts
View file @
a7b0b5fa
...
...
@@ -30,3 +30,33 @@ describe('chrome-devtools-workspace default', () => {
}
})
})
describe
(
'chrome-devtools-workspace proxy'
,
()
=>
{
const
{
isNextDev
,
next
}
=
nextTestSetup
({
files
:
path
.
join
(
__dirname
,
'fixtures'
,
'proxy'
),
})
it
(
'should be able to connect to Chrome DevTools in dev'
,
async
()
=>
{
const
devtoolsResponse
=
await
next
.
fetch
(
'/.well-known/appspecific/com.chrome.devtools.json'
)
if
(
isNextDev
)
{
const
json
=
await
devtoolsResponse
.
json
()
expect
(
json
).
toEqual
({
workspace
:
{
uuid
:
expect
.
any
(
String
),
root
:
next
.
testDir
,
},
})
const
pageReload
=
await
next
.
fetch
(
'/.well-known/appspecific/com.chrome.devtools.json'
)
// The UUID should be stable across reloads.
// Otherwise you'd have to reconnect every-time.
expect
(
await
pageReload
.
json
()).
toEqual
(
json
)
}
else
{
expect
({
status
:
devtoolsResponse
.
status
}).
toEqual
({
status
:
404
})
}
})
})
test/e2e/chrome-devtools-workspace/fixtures/proxy/app/[lang]/page.js
0 → 100644
View file @
a7b0b5fa
export
default
async
function
Page
({
params
})
{
const
{
lang
}
=
await
params
return
`Hello,
${
lang
}
Dave!`
}
test/e2e/chrome-devtools-workspace/fixtures/proxy/app/layout.js
0 → 100644
View file @
a7b0b5fa
import
{
Suspense
}
from
'react'
export
default
function
Root
({
children
})
{
return
(
<
html
>
<
body
>
<
Suspense
fallback
=
"loading"
>
{
children
}
<
/Suspense
>
<
/body
>
<
/html
>
)
}
test/e2e/chrome-devtools-workspace/fixtures/proxy/next.config.js
0 → 100644
View file @
a7b0b5fa
/**
* @type {import('next').NextConfig}
*/
const
nextConfig
=
{}
module
.
exports
=
nextConfig
test/e2e/chrome-devtools-workspace/fixtures/proxy/proxy.js
0 → 100644
View file @
a7b0b5fa
import
{
NextResponse
}
from
'next/server'
export
function
proxy
(
request
,
context
)
{
const
url
=
new
URL
(
request
.
url
)
url
.
pathname
=
`/en-EN
${
url
.
pathname
}
`
return
NextResponse
.
rewrite
(
url
)
}
export
const
config
=
{
// Matcher ignoring `/_next/`, `/api/`, static assets, favicon, etc.
matcher
:
[
'/((?!api|_next/static|_next/image|favicon.ico).*)'
],
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment