-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace externalFetch with handleFetch #6565
Conversation
🦋 Changeset detectedLatest commit: ecf3ecb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for kit-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Do you think it makes sense to call out the cookie sibling subdomain thing explicitly in the docs? Can we do that without it being too confusing? We've heard from a few people that it took then a while to even understand why their app wasn't working, so this might also be a good opportunity to tell people how the default conservative cookie passing works. |
Excellent point. Does b96a5fd spark joy? (I will settle for 'it is coherent and correct') |
Maybe write the code to check Edit: Oh, we don't have a URL instance here necessarily. Should we normalize it so that we do? |
in the code or in the docs? |
Uh. I had meant in the code, but in the docs might suffice, as long as they are careful not to instantiate URLs from relative |
There's no such thing — if you create a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading over the documentation changes and code, I think this'll work great for my use case. Thank you for considering it and making changes to the API.
Migration guide
externalFetch
has been replaced withhandleFetch
. WhereasexternalFetch
only ran when yourload
function contained afetch
call for an external URL,handleFetch
runs for allfetch
calls inload
that run on the server. Instead of receiving arequest
argument, it receives{ event, request, fetch }
, whereevent
is the underlyingRequestEvent
andfetch
is SvelteKit's internalfetch
implementation.Original PR description
Supersedes part of #6541
Closes #5253
Closes #5195
Closes #4750
This replaces
externalFetch
with a newhandleFetch
hook, which gives developers the ability to forward whichever headers they need on a case-by-case basis — so for example if yourload
function looks like this......the
fetch
will be made without any non-default headers, but you can add custom headers insidehandleFetch
:If unimplemented, defaults to
({ request, fetch }) => fetch(request)
.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0