Skip to content

Commit 36ccad3

Browse files
fix: custom server hook context request.path should carry query str (#6127)
1 parent 9e82b00 commit 36ccad3

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.changeset/hot-stingrays-sing.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@modern-js/server-core': patch
3+
---
4+
5+
fix: custom server hook context request.path should carray query str
6+
fix: custom server hook context request.path 应该带上 query 字符串

packages/server/core/src/plugins/customServer/base.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ class BaseHookRequest implements ModernRequest {
6161

6262
get url(): string {
6363
// compat old middlwares,
64-
return this.#req.path;
64+
65+
const query = this.#c.req.query();
66+
const q = Object.entries(query)
67+
.map(([key, value]) => `${key}=${value}`)
68+
.join('&');
69+
return q ? `${this.#c.req.path}?${q}` : this.#c.req.path;
6570
}
6671

6772
// TODO: remove next major version

0 commit comments

Comments
 (0)