-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: skip calling
respond
for server-side fetch
on prerendered pa…
…ges (#13377) When using server-side fetch for internal requests, if a server route is matched from the server `manifest.js`, it gets called without making a real HTTP request. However, prerendered routes are not included on this list! This is fine when routes are prerendered with `export const prerender = true;`, but will cause issues with a non-prerendered route also matches the same URL as any prerendered routes. This commit adds `prerendered_routes: Set<string>` to the `manifest.js`, which skips calling the non-prerendered route. Fixes #12778 Fixes #12739
- Loading branch information
1 parent
f30352f
commit d62ed39
Showing
13 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
fix: skip hooks for server fetch to prerendered routes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
fix: default server fetch to use prerendered paths |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...ps/basics/src/routes/prerendering/prerendered-endpoint/api-with-param/[option]/+server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { building, dev } from '$app/environment'; | ||
import { error, json } from '@sveltejs/kit'; | ||
|
||
export const prerender = 'auto'; | ||
|
||
export function entries() { | ||
return [ | ||
{ | ||
option: 'prerendered' | ||
} | ||
]; | ||
} | ||
|
||
export async function GET({ params: { option } }) { | ||
if ((await entries()).find((entry) => entry.option === option)) { | ||
if (dev || building) { | ||
return json({ message: 'Im prerendered and called from a non-prerendered +page.server.js' }); | ||
} else { | ||
error(500, 'I should not be called at runtime because I am prerendered'); | ||
} | ||
} | ||
return json({ message: 'Im not prerendered' }); | ||
} |
6 changes: 5 additions & 1 deletion
6
packages/kit/test/apps/basics/src/routes/prerendering/prerendered-endpoint/proxy/+server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
export async function GET({ fetch }) { | ||
export async function GET({ fetch, url }) { | ||
if (url.searchParams.get('api-with-param-option') === 'prerendered') { | ||
return await fetch('/prerendering/prerendered-endpoint/api-with-param/prerendered'); | ||
} | ||
|
||
return await fetch('/prerendering/prerendered-endpoint/api'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters