react-router 7.15.1 → 7.18.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/CHANGELOG.md +73 -2
  2. package/dist/development/{browser-BOdXz9dK.d.ts → browser-7x6a6gQP.d.ts} +2 -2
  3. package/dist/development/{browser-3AnU12UI.d.mts → browser-CiGxXXOl.d.mts} +2 -2
  4. package/dist/development/{chunk-D6LUOGOQ.js → chunk-2ZBLYC7V.js} +265 -57
  5. package/dist/development/{chunk-4N6VE7H7.mjs → chunk-6KYCQHYJ.mjs} +268 -60
  6. package/dist/{production/chunk-Y6IFXO7V.js → development/chunk-IFHLIXZW.js} +7 -7
  7. package/dist/development/{chunk-RJYABSBD.mjs → chunk-JAHXRPFV.mjs} +71 -122
  8. package/dist/development/{chunk-66UKHEGQ.js → chunk-NDF5KBLP.js} +112 -108
  9. package/dist/{production/context-ByvtofY2.d.mts → development/context-BlYKn1tE.d.mts} +24 -5
  10. package/dist/development/{data-BqZ2x964.d.ts → data-CjO11-hU.d.ts} +10 -2
  11. package/dist/{production/data-BVUf681J.d.mts → development/data-DEjBmEfD.d.mts} +10 -2
  12. package/dist/development/dom-export.d.mts +4 -4
  13. package/dist/development/dom-export.d.ts +4 -4
  14. package/dist/development/dom-export.js +61 -46
  15. package/dist/development/dom-export.mjs +39 -24
  16. package/dist/{production/index-react-server-client-BS5F89FR.d.ts → development/index-react-server-client-BaaZU3sM.d.ts} +32 -9
  17. package/dist/{production/index-react-server-client-DY04-103.d.mts → development/index-react-server-client-KK-TR-t7.d.mts} +20 -6
  18. package/dist/development/index-react-server-client.d.mts +3 -3
  19. package/dist/development/index-react-server-client.d.ts +3 -3
  20. package/dist/development/index-react-server-client.js +4 -4
  21. package/dist/development/index-react-server-client.mjs +2 -2
  22. package/dist/development/index-react-server.d.mts +20 -2
  23. package/dist/development/index-react-server.d.ts +20 -2
  24. package/dist/development/index-react-server.js +212 -144
  25. package/dist/development/index-react-server.mjs +211 -143
  26. package/dist/development/index.d.mts +22 -15
  27. package/dist/development/index.d.ts +22 -15
  28. package/dist/development/index.js +160 -211
  29. package/dist/development/index.mjs +3 -5
  30. package/dist/{production/instrumentation-cRWWLfsU.d.ts → development/instrumentation-CPkMwccd.d.ts} +12 -2
  31. package/dist/development/lib/types/internal.d.mts +2 -2
  32. package/dist/development/lib/types/internal.d.ts +2 -2
  33. package/dist/development/lib/types/internal.js +1 -1
  34. package/dist/development/lib/types/internal.mjs +1 -1
  35. package/dist/development/{register-Df8okEea.d.mts → register-CmkRspdl.d.mts} +1 -1
  36. package/dist/development/{register-Bsscfj79.d.ts → register-roq_0qYo.d.ts} +1 -1
  37. package/dist/production/{browser-BOdXz9dK.d.ts → browser-7x6a6gQP.d.ts} +2 -2
  38. package/dist/production/{browser-3AnU12UI.d.mts → browser-CiGxXXOl.d.mts} +2 -2
  39. package/dist/production/{chunk-PNZCCTKT.js → chunk-75HN637G.js} +112 -108
  40. package/dist/production/{chunk-JAKZPQZC.mjs → chunk-7RTFRKQW.mjs} +268 -60
  41. package/dist/production/{chunk-HUBUW7R3.js → chunk-HNBICOIU.js} +265 -57
  42. package/dist/production/{chunk-6S4627ZB.mjs → chunk-IAM5GYT3.mjs} +71 -122
  43. package/dist/{development/chunk-4YRVXM2U.js → production/chunk-K3NA4NUH.js} +7 -7
  44. package/dist/{development/context-ByvtofY2.d.mts → production/context-BlYKn1tE.d.mts} +24 -5
  45. package/dist/production/{data-BqZ2x964.d.ts → data-CjO11-hU.d.ts} +10 -2
  46. package/dist/{development/data-BVUf681J.d.mts → production/data-DEjBmEfD.d.mts} +10 -2
  47. package/dist/production/dom-export.d.mts +4 -4
  48. package/dist/production/dom-export.d.ts +4 -4
  49. package/dist/production/dom-export.js +61 -46
  50. package/dist/production/dom-export.mjs +39 -24
  51. package/dist/{development/index-react-server-client-BS5F89FR.d.ts → production/index-react-server-client-BaaZU3sM.d.ts} +32 -9
  52. package/dist/{development/index-react-server-client-DY04-103.d.mts → production/index-react-server-client-KK-TR-t7.d.mts} +20 -6
  53. package/dist/production/index-react-server-client.d.mts +3 -3
  54. package/dist/production/index-react-server-client.d.ts +3 -3
  55. package/dist/production/index-react-server-client.js +4 -4
  56. package/dist/production/index-react-server-client.mjs +2 -2
  57. package/dist/production/index-react-server.d.mts +20 -2
  58. package/dist/production/index-react-server.d.ts +20 -2
  59. package/dist/production/index-react-server.js +212 -144
  60. package/dist/production/index-react-server.mjs +211 -143
  61. package/dist/production/index.d.mts +22 -15
  62. package/dist/production/index.d.ts +22 -15
  63. package/dist/production/index.js +160 -211
  64. package/dist/production/index.mjs +3 -5
  65. package/dist/{development/instrumentation-cRWWLfsU.d.ts → production/instrumentation-CPkMwccd.d.ts} +12 -2
  66. package/dist/production/lib/types/internal.d.mts +2 -2
  67. package/dist/production/lib/types/internal.d.ts +2 -2
  68. package/dist/production/lib/types/internal.js +1 -1
  69. package/dist/production/lib/types/internal.mjs +1 -1
  70. package/dist/production/{register-Df8okEea.d.mts → register-CmkRspdl.d.mts} +1 -1
  71. package/dist/production/{register-Bsscfj79.d.ts → register-roq_0qYo.d.ts} +1 -1
  72. package/docs/explanation/backend-for-frontend.md +50 -0
  73. package/docs/explanation/code-splitting.md +61 -0
  74. package/docs/explanation/concurrency.md +135 -0
  75. package/docs/explanation/form-vs-fetcher.md +292 -0
  76. package/docs/explanation/hot-module-replacement.md +137 -0
  77. package/docs/explanation/hydration.md +14 -0
  78. package/docs/explanation/index-query-param.md +86 -0
  79. package/docs/explanation/index.md +4 -0
  80. package/docs/explanation/lazy-route-discovery.md +78 -0
  81. package/docs/explanation/location.md +6 -0
  82. package/docs/explanation/progressive-enhancement.md +150 -0
  83. package/docs/explanation/race-conditions.md +88 -0
  84. package/docs/explanation/react-transitions.md +160 -0
  85. package/docs/explanation/route-matching.md +7 -0
  86. package/docs/explanation/server-client-execution.md +4 -0
  87. package/docs/explanation/sessions-and-cookies.md +465 -0
  88. package/docs/explanation/special-files.md +16 -0
  89. package/docs/explanation/state-management.md +524 -0
  90. package/docs/explanation/styling.md +87 -0
  91. package/docs/explanation/type-safety.md +82 -0
  92. package/docs/how-to/accessibility.md +44 -0
  93. package/docs/how-to/client-data.md +199 -0
  94. package/docs/how-to/data-strategy.md +317 -0
  95. package/docs/how-to/error-boundary.md +231 -0
  96. package/docs/how-to/error-reporting.md +142 -0
  97. package/docs/how-to/fetchers.md +307 -0
  98. package/docs/how-to/file-route-conventions.md +410 -0
  99. package/docs/how-to/file-uploads.md +217 -0
  100. package/docs/how-to/form-validation.md +120 -0
  101. package/docs/how-to/headers.md +165 -0
  102. package/docs/how-to/index.md +4 -0
  103. package/docs/how-to/instrumentation.md +556 -0
  104. package/docs/how-to/meta.md +40 -0
  105. package/docs/how-to/middleware.md +763 -0
  106. package/docs/how-to/navigation-blocking.md +233 -0
  107. package/docs/how-to/optimize-revalidation.md +12 -0
  108. package/docs/how-to/pre-rendering.md +225 -0
  109. package/docs/how-to/presets.md +103 -0
  110. package/docs/how-to/react-server-components.md +899 -0
  111. package/docs/how-to/resource-routes.md +126 -0
  112. package/docs/how-to/route-module-type-safety.md +100 -0
  113. package/docs/how-to/search-params.md +4 -0
  114. package/docs/how-to/security.md +32 -0
  115. package/docs/how-to/server-bundles.md +66 -0
  116. package/docs/how-to/spa.md +120 -0
  117. package/docs/how-to/status.md +63 -0
  118. package/docs/how-to/suspense.md +132 -0
  119. package/docs/how-to/using-handle.md +117 -0
  120. package/docs/how-to/view-transitions.md +237 -0
  121. package/docs/how-to/webhook.md +50 -0
  122. package/docs/index.md +39 -0
  123. package/docs/start/data/actions.md +138 -0
  124. package/docs/start/data/custom.md +198 -0
  125. package/docs/start/data/data-loading.md +44 -0
  126. package/docs/start/data/index.md +4 -0
  127. package/docs/start/data/installation.md +56 -0
  128. package/docs/start/data/navigating.md +12 -0
  129. package/docs/start/data/pending-ui.md +12 -0
  130. package/docs/start/data/route-object.md +268 -0
  131. package/docs/start/data/routing.md +281 -0
  132. package/docs/start/data/testing.md +8 -0
  133. package/docs/start/declarative/index.md +4 -0
  134. package/docs/start/declarative/installation.md +43 -0
  135. package/docs/start/declarative/navigating.md +133 -0
  136. package/docs/start/declarative/routing.md +237 -0
  137. package/docs/start/declarative/url-values.md +65 -0
  138. package/docs/start/framework/actions.md +174 -0
  139. package/docs/start/framework/data-loading.md +201 -0
  140. package/docs/start/framework/deploying.md +100 -0
  141. package/docs/start/framework/index.md +4 -0
  142. package/docs/start/framework/installation.md +41 -0
  143. package/docs/start/framework/navigating.md +182 -0
  144. package/docs/start/framework/pending-ui.md +142 -0
  145. package/docs/start/framework/rendering.md +59 -0
  146. package/docs/start/framework/route-module.md +527 -0
  147. package/docs/start/framework/routing.md +362 -0
  148. package/docs/start/framework/testing.md +133 -0
  149. package/docs/start/index.md +4 -0
  150. package/docs/start/modes.md +201 -0
  151. package/docs/upgrading/component-routes.md +363 -0
  152. package/docs/upgrading/future.md +490 -0
  153. package/docs/upgrading/index.md +4 -0
  154. package/docs/upgrading/remix.md +403 -0
  155. package/docs/upgrading/router-provider.md +442 -0
  156. package/docs/upgrading/v6.md +382 -0
  157. package/package.json +2 -1
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }/**
2
- * react-router v7.15.1
2
+ * react-router v7.18.5
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -14,7 +14,7 @@
14
14
 
15
15
 
16
16
 
17
- var _chunkHUBUW7R3js = require('./chunk-HUBUW7R3.js');
17
+ var _chunk2ZBLYC7Vjs = require('./chunk-2ZBLYC7V.js');
18
18
 
19
19
  // lib/dom/ssr/hydration.tsx
20
20
  function getHydrationData({
@@ -29,12 +29,12 @@ function getHydrationData({
29
29
  ...state,
30
30
  loaderData: { ...state.loaderData }
31
31
  };
32
- let initialMatches = _chunkHUBUW7R3js.matchRoutes.call(void 0, routes, location, basename);
32
+ let initialMatches = _chunk2ZBLYC7Vjs.matchRoutes.call(void 0, routes, location, basename);
33
33
  if (initialMatches) {
34
34
  for (let match of initialMatches) {
35
35
  let routeId = match.route.id;
36
36
  let routeInfo = getRouteInfo(routeId);
37
- if (_chunkHUBUW7R3js.shouldHydrateRouteLoader.call(void 0,
37
+ if (_chunk2ZBLYC7Vjs.shouldHydrateRouteLoader.call(void 0,
38
38
  routeId,
39
39
  routeInfo.clientLoader,
40
40
  routeInfo.hasLoader,
@@ -112,7 +112,7 @@ function RSCDefaultRootErrorBoundaryImpl({
112
112
  }
113
113
  }
114
114
  );
115
- if (_chunkHUBUW7R3js.isRouteErrorResponse.call(void 0, error)) {
115
+ if (_chunk2ZBLYC7Vjs.isRouteErrorResponse.call(void 0, error)) {
116
116
  return /* @__PURE__ */ _react2.default.createElement(
117
117
  ErrorWrapper,
118
118
  {
@@ -120,7 +120,7 @@ function RSCDefaultRootErrorBoundaryImpl({
120
120
  title: "Unhandled Thrown Response!"
121
121
  },
122
122
  /* @__PURE__ */ _react2.default.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText),
123
- _chunkHUBUW7R3js.ENABLE_DEV_WARNINGS ? heyDeveloper : null
123
+ _chunk2ZBLYC7Vjs.ENABLE_DEV_WARNINGS ? heyDeveloper : null
124
124
  );
125
125
  }
126
126
  let errorInstance;
@@ -146,7 +146,7 @@ function RSCDefaultRootErrorBoundaryImpl({
146
146
  function RSCDefaultRootErrorBoundary({
147
147
  hasRootLayout
148
148
  }) {
149
- let error = _chunkHUBUW7R3js.useRouteError.call(void 0, );
149
+ let error = _chunk2ZBLYC7Vjs.useRouteError.call(void 0, );
150
150
  if (hasRootLayout === void 0) {
151
151
  throw new Error("Missing 'hasRootLayout' prop");
152
152
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.15.1
2
+ * react-router v7.18.5
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -32,11 +32,14 @@ import {
32
32
  decodeRouteErrorResponseDigest,
33
33
  decodeViaTurboStream,
34
34
  encode,
35
+ escapeAttribute,
35
36
  escapeHtml,
36
37
  getManifestPath,
37
38
  getStaticContextFromError,
39
+ hasInvalidProtocol,
38
40
  instrumentHandler,
39
41
  isDataWithResponseInit,
42
+ isFogOfWarEnabled,
40
43
  isMutationMethod,
41
44
  isRedirectResponse,
42
45
  isRedirectStatusCode,
@@ -48,13 +51,14 @@ import {
48
51
  redirectDocument,
49
52
  replace,
50
53
  shouldHydrateRouteLoader,
54
+ shouldUseInitialRouteDiscovery,
51
55
  stripBasename,
52
56
  useRouteError,
53
57
  warnOnce,
54
58
  withComponentProps,
55
59
  withErrorBoundaryProps,
56
60
  withHydrateFallbackProps
57
- } from "./chunk-4N6VE7H7.mjs";
61
+ } from "./chunk-6KYCQHYJ.mjs";
58
62
 
59
63
  // lib/dom/ssr/server.tsx
60
64
  import * as React from "react";
@@ -104,6 +108,7 @@ function ServerRouter({
104
108
  ssr: context.ssr,
105
109
  isSpaMode: context.isSpaMode,
106
110
  routeDiscovery: context.routeDiscovery,
111
+ nonce,
107
112
  serializeError: context.serializeError,
108
113
  renderMeta: context.renderMeta
109
114
  }
@@ -144,7 +149,7 @@ function createRoutesStub(routes, _context) {
144
149
  future: {
145
150
  v8_passThroughRequests: future?.v8_passThroughRequests === true,
146
151
  v8_middleware: future?.v8_middleware === true,
147
- unstable_trailingSlashAwareDataRequests: future?.unstable_trailingSlashAwareDataRequests === true
152
+ v8_trailingSlashAwareDataRequests: future?.v8_trailingSlashAwareDataRequests === true
148
153
  },
149
154
  manifest: {
150
155
  routes: {},
@@ -466,33 +471,6 @@ function serializeError(error, serverMode) {
466
471
  stack: sanitized.stack
467
472
  };
468
473
  }
469
- function serializeErrors(errors, serverMode) {
470
- if (!errors) return null;
471
- let entries = Object.entries(errors);
472
- let serialized = {};
473
- for (let [key, val] of entries) {
474
- if (isRouteErrorResponse(val)) {
475
- serialized[key] = { ...val, __type: "RouteErrorResponse" };
476
- } else if (val instanceof Error) {
477
- let sanitized = sanitizeError(val, serverMode);
478
- serialized[key] = {
479
- message: sanitized.message,
480
- stack: sanitized.stack,
481
- __type: "Error",
482
- // If this is a subclass (i.e., ReferenceError), send up the type so we
483
- // can re-create the same type during hydration. This will only apply
484
- // in dev mode since all production errors are sanitized to normal
485
- // Error instances
486
- ...sanitized.name !== "Error" ? {
487
- __subType: sanitized.name
488
- } : {}
489
- };
490
- } else {
491
- serialized[key] = val;
492
- }
493
- }
494
- return serialized;
495
- }
496
474
 
497
475
  // lib/server-runtime/invariant.ts
498
476
  function invariant(value, message) {
@@ -769,28 +747,29 @@ function prependCookies(parentHeaders, childHeaders) {
769
747
  }
770
748
 
771
749
  // lib/actions.ts
772
- function throwIfPotentialCSRFAttack(headers, allowedActionOrigins) {
773
- let originHeader = headers.get("origin");
750
+ function throwIfPotentialCSRFAttack(request, allowedActionOrigins) {
751
+ let originHeader = request.headers.get("origin");
774
752
  let originDomain = null;
753
+ let originUrl = null;
775
754
  try {
776
- originDomain = typeof originHeader === "string" && originHeader !== "null" ? new URL(originHeader).host : originHeader;
755
+ if (typeof originHeader === "string" && originHeader !== "null") {
756
+ originUrl = new URL(originHeader);
757
+ originDomain = originUrl.host;
758
+ } else {
759
+ originDomain = originHeader;
760
+ }
777
761
  } catch {
778
762
  throw new Error(
779
763
  `\`origin\` header is not a valid URL. Aborting the action.`
780
764
  );
781
765
  }
782
- let host = parseHostHeader(headers);
783
- if (originDomain && (!host || originDomain !== host.value)) {
766
+ let requestUrl = new URL(request.url);
767
+ let originMatchesRequest = originUrl ? originUrl.origin === requestUrl.origin : originDomain === requestUrl.host;
768
+ if (originDomain && !originMatchesRequest) {
784
769
  if (!isAllowedOrigin(originDomain, allowedActionOrigins)) {
785
- if (host) {
786
- throw new Error(
787
- `${host.type} header does not match \`origin\` header from a forwarded action request. Aborting the action.`
788
- );
789
- } else {
790
- throw new Error(
791
- "`x-forwarded-host` or `host` headers are not provided. One of these is needed to compare the `origin` header from a forwarded action request. Aborting the action."
792
- );
793
- }
770
+ throw new Error(
771
+ "The `request.url` origin does not match `origin` header from a forwarded action request. Aborting the action."
772
+ );
794
773
  }
795
774
  }
796
775
  }
@@ -838,25 +817,13 @@ function isAllowedOrigin(originDomain, allowedActionOrigins = []) {
838
817
  (allowedOrigin) => allowedOrigin && (allowedOrigin === originDomain || matchWildcardDomain(originDomain, allowedOrigin))
839
818
  );
840
819
  }
841
- function parseHostHeader(headers) {
842
- let forwardedHostHeader = headers.get("x-forwarded-host");
843
- let forwardedHostValue = forwardedHostHeader?.split(",")[0]?.trim();
844
- let hostHeader = headers.get("host");
845
- return forwardedHostValue ? {
846
- type: "x-forwarded-host",
847
- value: forwardedHostValue
848
- } : hostHeader ? {
849
- type: "host",
850
- value: hostHeader
851
- } : void 0;
852
- }
853
820
 
854
821
  // lib/server-runtime/urls.ts
855
822
  function getNormalizedPath(request, basename, future) {
856
823
  basename = basename || "/";
857
824
  let url = new URL(request.url);
858
825
  let pathname = url.pathname;
859
- if (future?.unstable_trailingSlashAwareDataRequests) {
826
+ if (future?.v8_trailingSlashAwareDataRequests) {
860
827
  if (pathname.endsWith("/_.data")) {
861
828
  pathname = pathname.replace(/_\.data$/, "");
862
829
  } else {
@@ -895,7 +862,7 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
895
862
  try {
896
863
  try {
897
864
  throwIfPotentialCSRFAttack(
898
- request.headers,
865
+ request,
899
866
  Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []
900
867
  );
901
868
  } catch (e) {
@@ -1225,7 +1192,7 @@ function derive(build, mode) {
1225
1192
  }
1226
1193
  if (build.prerender.length === 0) {
1227
1194
  isSpaMode = true;
1228
- } else if (!build.prerender.includes(decodedPath) && !build.prerender.includes(decodedPath + "/")) {
1195
+ } else if (!build.prerender.includes(decodedPath.replace(/\/$/, "")) && !build.prerender.includes(decodedPath.replace(/[^/]$/, "/"))) {
1229
1196
  if (requestUrl.pathname.endsWith(".data")) {
1230
1197
  errorHandler(
1231
1198
  new ErrorResponseImpl(
@@ -1252,7 +1219,7 @@ function derive(build, mode) {
1252
1219
  build.routeDiscovery.manifestPath,
1253
1220
  build.basename
1254
1221
  );
1255
- if (requestUrl.pathname === manifestUrl) {
1222
+ if (build.routeDiscovery.mode === "lazy" && requestUrl.pathname === manifestUrl) {
1256
1223
  try {
1257
1224
  let res = await handleManifestRequest(
1258
1225
  build,
@@ -1386,6 +1353,12 @@ var createRequestHandler = (build, mode) => {
1386
1353
  };
1387
1354
  };
1388
1355
  async function handleManifestRequest(build, dataRoutes, branches, url) {
1356
+ if (url.toString().length > URL_LIMIT) {
1357
+ return new Response(null, {
1358
+ statusText: "Bad Request",
1359
+ status: 400
1360
+ });
1361
+ }
1389
1362
  if (build.assets.version !== url.searchParams.get("version")) {
1390
1363
  return new Response(null, {
1391
1364
  status: 204,
@@ -1394,28 +1367,14 @@ async function handleManifestRequest(build, dataRoutes, branches, url) {
1394
1367
  }
1395
1368
  });
1396
1369
  }
1397
- if (url.toString().length > URL_LIMIT) {
1398
- return new Response(null, {
1399
- statusText: "Bad Request",
1400
- status: 400
1401
- });
1402
- }
1403
1370
  let patches = {};
1404
1371
  if (url.searchParams.has("paths")) {
1405
- let paths = /* @__PURE__ */ new Set();
1406
1372
  let pathParam = url.searchParams.get("paths") || "";
1407
- let requestedPaths = pathParam.split(",").filter(Boolean);
1408
- requestedPaths.forEach((path) => {
1373
+ let paths = new Set(pathParam.split(",").filter(Boolean));
1374
+ for (let path of paths) {
1409
1375
  if (!path.startsWith("/")) {
1410
1376
  path = `/${path}`;
1411
1377
  }
1412
- let segments = path.split("/").slice(1);
1413
- segments.forEach((_, i) => {
1414
- let partialPath = segments.slice(0, i + 1).join("/");
1415
- paths.add(`/${partialPath}`);
1416
- });
1417
- });
1418
- for (let path of paths) {
1419
1378
  let matches = matchServerRoutes(
1420
1379
  build.routes,
1421
1380
  dataRoutes,
@@ -1468,7 +1427,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
1468
1427
  if (isMutationMethod(request.method)) {
1469
1428
  try {
1470
1429
  throwIfPotentialCSRFAttack(
1471
- request.headers,
1430
+ request,
1472
1431
  Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []
1473
1432
  );
1474
1433
  } catch (e) {
@@ -1516,12 +1475,19 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
1516
1475
  let state = {
1517
1476
  loaderData: context.loaderData,
1518
1477
  actionData: context.actionData,
1519
- errors: serializeErrors(context.errors, serverMode)
1478
+ errors: context.errors
1520
1479
  };
1480
+ let routeDiscovery = build.routeDiscovery;
1481
+ if (isFogOfWarEnabled(routeDiscovery, build.ssr) && shouldUseInitialRouteDiscovery(
1482
+ context.location.pathname,
1483
+ staticHandler._matchCost
1484
+ )) {
1485
+ routeDiscovery = { ...routeDiscovery, mode: "initial" };
1486
+ }
1521
1487
  let baseServerHandoff = {
1522
1488
  basename: build.basename,
1523
1489
  future: build.future,
1524
- routeDiscovery: build.routeDiscovery,
1490
+ routeDiscovery,
1525
1491
  ssr: build.ssr,
1526
1492
  isSpaMode: isSpaMode2
1527
1493
  };
@@ -1544,7 +1510,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
1544
1510
  renderMeta: {},
1545
1511
  future: build.future,
1546
1512
  ssr: build.ssr,
1547
- routeDiscovery: build.routeDiscovery,
1513
+ routeDiscovery,
1548
1514
  isSpaMode: isSpaMode2,
1549
1515
  serializeError: (err) => serializeError(err, serverMode)
1550
1516
  };
@@ -1582,7 +1548,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
1582
1548
  let state2 = {
1583
1549
  loaderData: context.loaderData,
1584
1550
  actionData: context.actionData,
1585
- errors: serializeErrors(context.errors, serverMode)
1551
+ errors: context.errors
1586
1552
  };
1587
1553
  entryContext = {
1588
1554
  ...entryContext,
@@ -2178,6 +2144,9 @@ async function routeRSCServerRequest({
2178
2144
  detectRedirectResponse.body
2179
2145
  );
2180
2146
  if (serverResponse.status === SINGLE_FETCH_REDIRECT_STATUS && payload.type === "redirect") {
2147
+ if (hasInvalidProtocol(payload.location)) {
2148
+ throw new Error("Invalid redirect location");
2149
+ }
2181
2150
  const headers2 = new Headers(serverResponse.headers);
2182
2151
  headers2.delete("Content-Encoding");
2183
2152
  headers2.delete("Content-Length");
@@ -2221,6 +2190,9 @@ async function routeRSCServerRequest({
2221
2190
  }
2222
2191
  headers.set("Content-Type", "text/html; charset=utf-8");
2223
2192
  if (renderRedirect) {
2193
+ if (hasInvalidProtocol(renderRedirect.location)) {
2194
+ throw new Error("Invalid redirect location");
2195
+ }
2224
2196
  headers.set("Location", renderRedirect.location);
2225
2197
  return new Response(html, {
2226
2198
  status: renderRedirect.status,
@@ -2230,9 +2202,12 @@ async function routeRSCServerRequest({
2230
2202
  const redirectTransform = new TransformStream({
2231
2203
  flush(controller) {
2232
2204
  if (renderRedirect) {
2205
+ if (hasInvalidProtocol(renderRedirect.location)) {
2206
+ return;
2207
+ }
2233
2208
  controller.enqueue(
2234
2209
  new TextEncoder().encode(
2235
- `<meta http-equiv="refresh" content="0;url=${escapeHtml(renderRedirect.location)}"/>`
2210
+ `<meta http-equiv="refresh" content="0;url=${escapeAttribute(renderRedirect.location)}"/>`
2236
2211
  )
2237
2212
  );
2238
2213
  }
@@ -2259,6 +2234,9 @@ async function routeRSCServerRequest({
2259
2234
  return error;
2260
2235
  }
2261
2236
  if (renderRedirect) {
2237
+ if (hasInvalidProtocol(renderRedirect.location)) {
2238
+ throw new Error("Invalid redirect location");
2239
+ }
2262
2240
  return new Response(`Redirect: ${renderRedirect.location}`, {
2263
2241
  status: renderRedirect.status,
2264
2242
  headers: {
@@ -2332,6 +2310,9 @@ async function routeRSCServerRequest({
2332
2310
  }
2333
2311
  headers.set("Content-Type", "text/html; charset=utf-8");
2334
2312
  if (retryRedirect) {
2313
+ if (hasInvalidProtocol(retryRedirect.location)) {
2314
+ throw new Error("Invalid redirect location");
2315
+ }
2335
2316
  headers.set("Location", retryRedirect.location);
2336
2317
  return new Response(html, {
2337
2318
  status: retryRedirect.status,
@@ -2341,9 +2322,12 @@ async function routeRSCServerRequest({
2341
2322
  const retryRedirectTransform = new TransformStream({
2342
2323
  flush(controller) {
2343
2324
  if (retryRedirect) {
2325
+ if (hasInvalidProtocol(retryRedirect.location)) {
2326
+ return;
2327
+ }
2344
2328
  controller.enqueue(
2345
2329
  new TextEncoder().encode(
2346
- `<meta http-equiv="refresh" content="0;url=${escapeHtml(retryRedirect.location)}"/>`
2330
+ `<meta http-equiv="refresh" content="0;url=${escapeAttribute(retryRedirect.location)}"/>`
2347
2331
  )
2348
2332
  );
2349
2333
  }
@@ -2374,6 +2358,9 @@ function RSCStaticRouter({ getPayload }) {
2374
2358
  const decoded = getPayload();
2375
2359
  const payload = useSafe(decoded);
2376
2360
  if (payload.type === "redirect") {
2361
+ if (hasInvalidProtocol(payload.location)) {
2362
+ throw new Error("Invalid redirect location");
2363
+ }
2377
2364
  throw new Response(null, {
2378
2365
  status: payload.status,
2379
2366
  headers: {
@@ -2451,7 +2438,7 @@ function RSCStaticRouter({ getPayload }) {
2451
2438
  // These flags have no runtime impact so can always be false. If we add
2452
2439
  // flags that drive runtime behavior they'll need to be proxied through.
2453
2440
  v8_middleware: false,
2454
- unstable_trailingSlashAwareDataRequests: true,
2441
+ v8_trailingSlashAwareDataRequests: true,
2455
2442
  // always on for RSC
2456
2443
  v8_passThroughRequests: true
2457
2444
  // always on for RSC
@@ -2491,43 +2478,6 @@ function isManifestRequest(url) {
2491
2478
  return url.pathname.endsWith(".manifest");
2492
2479
  }
2493
2480
 
2494
- // lib/dom/ssr/errors.ts
2495
- function deserializeErrors(errors) {
2496
- if (!errors) return null;
2497
- let entries = Object.entries(errors);
2498
- let serialized = {};
2499
- for (let [key, val] of entries) {
2500
- if (val && val.__type === "RouteErrorResponse") {
2501
- serialized[key] = new ErrorResponseImpl(
2502
- val.status,
2503
- val.statusText,
2504
- val.data,
2505
- val.internal === true
2506
- );
2507
- } else if (val && val.__type === "Error") {
2508
- if (val.__subType) {
2509
- let ErrorConstructor = window[val.__subType];
2510
- if (typeof ErrorConstructor === "function") {
2511
- try {
2512
- let error = new ErrorConstructor(val.message);
2513
- error.stack = val.stack;
2514
- serialized[key] = error;
2515
- } catch (e) {
2516
- }
2517
- }
2518
- }
2519
- if (serialized[key] == null) {
2520
- let error = new Error(val.message);
2521
- error.stack = val.stack;
2522
- serialized[key] = error;
2523
- }
2524
- } else {
2525
- serialized[key] = val;
2526
- }
2527
- }
2528
- return serialized;
2529
- }
2530
-
2531
2481
  // lib/dom/ssr/hydration.tsx
2532
2482
  function getHydrationData({
2533
2483
  state,
@@ -2580,6 +2530,5 @@ export {
2580
2530
  populateRSCRouteModules,
2581
2531
  routeRSCServerRequest,
2582
2532
  RSCStaticRouter,
2583
- deserializeErrors,
2584
2533
  getHydrationData
2585
2534
  };