-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Preserve the original request when using adapter-node #8171
Preserve the original request when using adapter-node #8171
Conversation
🦋 Changeset detectedLatest commit: d671805 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 |
@chrskerr is attempting to deploy a commit to the Svelte Team on Vercel. A member of the Team first needs to authorize it. |
85a3998
to
38f774f
Compare
This has come up before - I don't remember whether there's still an open issue about it. But this API isn't how we would want to do it anyway - we shouldn't be throwing additional values onto the request object. |
Thanks @Conduitry! I have pushed again with the keys inserted into platform rather than the request. There will now be naming and other implications which I haven't completed yet, but if you are happy with this general approach then I will finish it off :) Thanks! |
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.
Is there any drawback to pass on the whole req
object to platform
? That would remove the need for the config option.
server.response(request, { req }, ..)
No concern from my end, I had just gone the other way on a guess that more specificity would be preferred. Naming wise, I was thinking |
42ffef8
to
4ca9d40
Compare
@dummdidumm @Conduitry sorry to chase, just keen to know what I can do to get this mergable please 🙂 it will be a huge help for our app |
Code-wise this looks good, only open point to me is the name (who would have thought 😄 ). |
I had leant towards Having said that I'm personally okay with both naming choices, the simplicity of |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Moved the declaration to Though in order to get types for the custom properties, you'd need to do something like this: declare namespace App {
export interface Platform {
req: import('http').IncomingMessage & {
sessionID: string;
user: {...}
};
}
} I still think That said, pragmatism may require us to look the other way, so if other maintainers are in favour of this change then I won't kick up a stink. |
Consensus was that we should do this. Thanks! |
The purpose of this PR is to retain access to the original request from Express during SvelteKit SSR.
We run session and auth middleware on all Express requests before we invoke the SvelteKit adapter-node handler. These set keys (
sessionID
anduser
) on the request object which can then be used within other handlers to assess auth status.This PR will allow us to access these from the originalReq object and extend our auth mechanism into sveltekit.
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