diff --git a/.changeset/kind-shirts-turn.md b/.changeset/kind-shirts-turn.md new file mode 100644 index 0000000000..dc26b6af24 --- /dev/null +++ b/.changeset/kind-shirts-turn.md @@ -0,0 +1,5 @@ +--- +"@react-router/dev": patch +--- + +Escape redirect locations in prerendered redirect HTML diff --git a/packages/react-router-dev/vite/plugin.ts b/packages/react-router-dev/vite/plugin.ts index 6eaf1297a3..6dd897b04f 100644 --- a/packages/react-router-dev/vite/plugin.ts +++ b/packages/react-router-dev/vite/plugin.ts @@ -2752,15 +2752,17 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = () => { // A short delay causes Google to interpret the redirect as temporary. // https://developers.google.com/search/docs/crawling-indexing/301-redirects#metarefresh let delay = response.status === 302 ? 2 : 0; + let escapedLocation = escapeHtml(location ?? ""); + let escapedPathname = escapeHtml(pathname); html = `
-${pathname} to ${location}
+
+ Redirecting from ${escapedPathname} to ${escapedLocation}