Skip to content

Commit 748bf13

Browse files
committed
Avoid circular ddependency
1 parent 1dbaf2b commit 748bf13

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

packages/react-router/lib/dom/ssr/single-fetch.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { createRequestInit } from "./data";
1818
import type { AssetsManifest, EntryContext } from "./entry";
1919
import { escapeHtml } from "./markup";
2020
import invariant from "./invariant";
21-
import { SINGLE_FETCH_REDIRECT_STATUS } from "../../server-runtime/single-fetch";
2221
import type { RouteModules } from "./routeModules";
2322
import type { DataRouteMatch } from "../../context";
2423

@@ -57,6 +56,13 @@ interface StreamTransferProps {
5756
nonce?: string;
5857
}
5958

59+
// We can't use a 3xx status or else the `fetch()` would follow the redirect.
60+
// We need to communicate the redirect back as data so we can act on it in the
61+
// client side router. We use a 202 to avoid any automatic caching we might
62+
// get from a 200 since a "temporary" redirect should not be cached. This lets
63+
// the user control cache behavior via Cache-Control
64+
export const SINGLE_FETCH_REDIRECT_STATUS = 202;
65+
6066
// Some status codes are not permitted to have bodies, so we want to just
6167
// treat those as "no data" instead of throwing an exception:
6268
// https://datatracker.ietf.org/doc/html/rfc9110#name-informational-1xx

packages/react-router/lib/server-runtime/server.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import {
2929
getSingleFetchRedirect,
3030
singleFetchAction,
3131
singleFetchLoaders,
32-
SINGLE_FETCH_REDIRECT_STATUS,
3332
SERVER_NO_BODY_STATUS_CODES,
3433
} from "./single-fetch";
3534
import { getDocumentHeaders } from "./headers";
@@ -38,7 +37,10 @@ import type {
3837
SingleFetchResult,
3938
SingleFetchResults,
4039
} from "../dom/ssr/single-fetch";
41-
import { SingleFetchRedirectSymbol } from "../dom/ssr/single-fetch";
40+
import {
41+
SINGLE_FETCH_REDIRECT_STATUS,
42+
SingleFetchRedirectSymbol,
43+
} from "../dom/ssr/single-fetch";
4244
import type { MiddlewareEnabled } from "../types/future";
4345

4446
export type RequestHandler = (

packages/react-router/lib/server-runtime/single-fetch.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type {
2020
} from "../dom/ssr/single-fetch";
2121
import {
2222
NO_BODY_STATUS_CODES,
23+
SINGLE_FETCH_REDIRECT_STATUS,
2324
SingleFetchRedirectSymbol,
2425
} from "../dom/ssr/single-fetch";
2526
import type { AppLoadContext } from "./data";
@@ -28,13 +29,6 @@ import { ServerMode } from "./mode";
2829
import { getDocumentHeaders } from "./headers";
2930
import type { ServerBuild } from "./build";
3031

31-
// We can't use a 3xx status or else the `fetch()` would follow the redirect.
32-
// We need to communicate the redirect back as data so we can act on it in the
33-
// client side router. We use a 202 to avoid any automatic caching we might
34-
// get from a 200 since a "temporary" redirect should not be cached. This lets
35-
// the user control cache behavior via Cache-Control
36-
export const SINGLE_FETCH_REDIRECT_STATUS = 202;
37-
3832
// Add 304 for server side - that is not included in the client side logic
3933
// because the browser should fill those responses with the cached data
4034
// https://datatracker.ietf.org/doc/html/rfc9110#name-304-not-modified

0 commit comments

Comments
 (0)