Static output drops query parameters from useRouter().url after hydration
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 66/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, typescript, vite
- Lĩnh vực
- frontend
Hướng nghiên cứu
Start by locating the React adapter's RouteResource and the router facade that compares the browser URL with pageData.url; the report identifies this as the suspected failure point. Reproduce with a static build and the provided /ssg?foo=bar#baz URL, then check the router's query string and searchParams after hydration. Done means the pathname still selects the static page while the router exposes the visitor's query parameters.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
In a fully static React Pages deployment, useRouter().url omits the visitor's query parameters, even though they remain in the browser address bar.
Versions:
Live reproduction
https://query-bug.yangshun.workers.dev/ssg?foo=bar#baz
After successful hydration, the page renders:
{
"href": "https://query-bug.yangshun.workers.dev/ssg",
"pathname": "/ssg",
"search": "",
"searchParams": [],
"hash": "#baz"
}
The browser URL still contains ?foo=bar. There are no browser warnings or errors.
Steps to reproduce
- Configure a React Pages app for static output:
// void.config.ts
import { defineConfig } from 'void/config';
export default defineConfig({
target: 'cloudflare',
output: 'static',
});
- Add a page that displays the router's query string:
// pages/ssg.tsx
import { useRouter } from '@void/react';
export default function Ssg() {
const router = useRouter();
return <pre>{router.url.search || '(empty)'}</pre>;
}
- Ensure there are no pages with
prerender = falseor other server features. - Deploy using
npx void deploy. The CLI identifies the deployment as Static Site. - Open
/ssg?foo=bar.
This also reproduces when serving the generated static files locally:
pnpm exec void prepare
pnpm exec vite build
python3 -m http.server 4173 --directory dist/client
With Python's static server, open http://localhost:4173/ssg.html?foo=bar#baz.
Expected
router.url.search is "?foo=bar", and router.url.searchParams.get('foo') returns "bar".
Actual
router.url.search is "", and router.url.searchParams is empty.
Framework comparison
With Void and all adapters at 1.1.11, Vue 3.5.44, Svelte 5.57.2, and Solid 1.9.17 all preserve ?foo=bar and #123 after hydration in local static production builds, without browser errors. Only React loses the query string; React was also verified on Cloudflare. This appears React-specific.
Suspected cause
The prerendered __VOID_PAGE_DATA__ payload contains "url":"/ssg".
In the React adapter's RouteResource, the router facade compares the browser's pathname plus search against pageData.url. Because /ssg?foo=bar differs from /ssg, it falls back to the build-time URL, losing the query parameters.
Selecting static files by pathname is correct, but the client router should still expose the visitor's query parameters.
- Ngôn ngữ chính
- TypeScript
- Star
- 402
- Fork
- 32
- Merge trung bình
- 11 giờ 52 phút
- Pull request đã merge (30 ngày)
- 88
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của voidzero-dev/void
-
bug
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
voidzero-dev/void#428 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
voidzero-dev/void#511 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Platform email: outbound-only custom domain for an apex whose MX belongs to another providerĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
voidzero-dev/void#510 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 58/100
voidzero-dev/void#509 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
voidzero-dev/void#507 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của voidzero-dev/void
Issue tương tự
-
area:editor bug issue-form:bug P0 platform:windows review: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
1lck/Lithe-IDEA#1388 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
fix(api): isToolAuditEnabled swallows database read errors on auditToolOperations without loggingĐang mởarea: backend bug priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
snapotter-hq/SnapOtter#3238 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
rig up --plan times out after 5 s and reports an UNKNOWN outcome while the daemon completes the planĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
filesystem: search_files does not expand non-wildcard excludePatterns like directory_tree doesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
modelcontextprotocol/servers#5216 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày