fix: support forwarded dev server refresh

This commit is contained in:
2026-07-08 17:45:02 +08:00
parent e4915f327c
commit 6076063be0
2 changed files with 8 additions and 3 deletions

View File

@@ -69,7 +69,12 @@ const trpcLinkOptions = {
const sep = input.includes('?') ? '&' : '?';
url = `${input}${sep}_t=${Date.now()}`;
} else {
url = input as string;
const requestUrl = new URL(input.url);
requestUrl.searchParams.set('_t', Date.now().toString());
return globalThis.fetch(new Request(requestUrl.toString(), input), {
...(init ?? {}),
credentials: "include",
});
}
return globalThis.fetch(url, {
...(init ?? {}),

View File

@@ -12,8 +12,8 @@ const SERVER_ROOT = path.dirname(fileURLToPath(import.meta.url));
export async function setupVite(app: Express, server: Server) {
const serverOptions = {
middlewareMode: true,
// Disable Vite client-side auto reload/HMR in dev.
hmr: false as const,
// Reuse the app HTTP server for HMR so SSH forwarding only needs the app port.
hmr: { server },
allowedHosts: true as const,
};