-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* pr 2861 rebase * merge headers from request * Revert "merge headers from request" This reverts commit 6f5308e. * Update packages/kit/src/runtime/server/page/load_node.js * omit cookie and authorization headers by default * all headers are single-valued, so use set rather than append * omit if-none-match, replace referer header * add test * changeset Co-authored-by: tom <anytable@gmail.com> Co-authored-by: Rich Harris <hello@rich-harris.dev>
- Loading branch information
1 parent
cf5d4aa
commit d98cc57
Showing
6 changed files
with
70 additions
and
4 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 | ||
--- | ||
|
||
Include page request headers in server-side fetches |
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
6 changes: 6 additions & 0 deletions
6
packages/kit/test/apps/basics/src/routes/load/fetch-headers.json.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,6 @@ | ||
/** @type {import('@sveltejs/kit').RequestHandler} */ | ||
export function get({ request }) { | ||
return { | ||
body: Object.fromEntries(request.headers) | ||
}; | ||
} |
26 changes: 26 additions & 0 deletions
26
packages/kit/test/apps/basics/src/routes/load/fetch-headers.svelte
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,26 @@ | ||
<script context="module"> | ||
/** @type {import('@sveltejs/kit').Load} */ | ||
export async function load({ fetch }) { | ||
const res = await fetch('/load/fetch-headers.json'); | ||
return { | ||
props: { | ||
headers: await res.json() | ||
} | ||
}; | ||
} | ||
</script> | ||
|
||
<script> | ||
/** @type {Record<string, string>} */ | ||
export let headers; | ||
const json = JSON.stringify({ | ||
'sec-fetch-dest': headers['sec-fetch-dest'], | ||
'sec-fetch-mode': headers['sec-fetch-mode'], | ||
'if-none-match': headers['if-none-match'], | ||
referer: headers['referer'] | ||
}); | ||
</script> | ||
|
||
<pre>{json}</pre> |
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