Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 6f8cd73

Browse files
committed
Skip redirect call in ssr
1 parent 53ceb63 commit 6f8cd73

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

framework/core/redirect.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import events from "./events.ts";
44
let routerReady = false;
55
let preRedirect: URL | null = null;
66

7+
const deno = typeof Deno === "object" && Deno !== null && typeof Deno.env === "object";
8+
79
const onrouterready = (_: Record<string, unknown>) => {
810
events.off("routerready", onrouterready);
911
if (preRedirect) {
@@ -15,12 +17,12 @@ const onrouterready = (_: Record<string, unknown>) => {
1517
events.on("routerready", onrouterready);
1618

1719
export function redirect(url: string, replace?: boolean) {
18-
const { location } = window;
19-
20-
if (!util.isFilledString(url)) {
20+
if (!util.isFilledString(url) || deno) {
2121
return;
2222
}
2323

24+
const { location } = window;
25+
2426
if (util.isLikelyHttpURL(url) || url.startsWith("file://") || url.startsWith("mailto:") || url.startsWith("data:")) {
2527
location.href = url;
2628
return;

framework/core/style.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const deno = typeof Deno !== "undefined" && typeof Deno.env === "object";
1+
const deno = typeof Deno === "object" && Deno !== null && typeof Deno.env === "object";
22

33
export function applyCSS(url: string, css: string) {
44
if (!deno) {

0 commit comments

Comments
 (0)