Skip to content
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

Support SvelteKit for getAuthCookieString and associated functions #311

Closed
kbrgl opened this issue Jul 9, 2022 · 7 comments
Closed

Support SvelteKit for getAuthCookieString and associated functions #311

kbrgl opened this issue Jul 9, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@kbrgl
Copy link

kbrgl commented Jul 9, 2022

Feature request

Support SvelteKit for getAuthCookieString and associated functions.

Is your feature request related to a problem? Please describe.

A breaking change in SvelteKit broke getAuthCookieString, setAuthCookie, deleteAuthCookie, etc. (sveltejs/kit#3384). This means server-side auth on SvelteKit is effectively broken, although you can use a workaround (supabase/supabase#5218).

Describe the solution you'd like

Support native fetch Request objects directly. One implementation approach may be to "expressify" these native requests by constructing a mock object which allows interop with the existing methods.

Describe alternatives you've considered

supabase/supabase#5218

@kbrgl kbrgl added the enhancement New feature or request label Jul 9, 2022
@kbrgl
Copy link
Author

kbrgl commented Jul 9, 2022

Happy to send a PR if necessary, but before I do I think this feature warrants a discussion on what the API will look like.

@mayank99
Copy link

Worth mentioning that this is about more than just sveltekit. The web fetch API is the standard all new frameworks/runtimes (remix, astro, cloudflare workers, bun, fresh) seem to be adopting. I wouldn't be surprised if even Next.js does the same in a future release; they are already doing that for their new edge functions.

By supporting the fetch API, supabase would automatically add support for all of these.

@silentworks
Copy link
Contributor

These methods are specific to this library being used with the Supabase stack, it doesn't break SvelteKit as you can construct, get and delete the cookie in your own application with your own methods. One of the methods is even marked that it is to work with Next and express. https://github.com/supabase/gotrue-js/blob/36856e719d16a71bc1fbef49dcde0d98df52e164/src/GoTrueApi.ts#L487-L488 If you need this functionality out of the box take a look at https://github.com/supabase-community/auth-helpers/tree/main/packages/sveltekit

@kbrgl
Copy link
Author

kbrgl commented Jul 16, 2022

Thanks for sharing the auth-helpers repo!

Would it be possible to get official documentation on how to construct, get, and delete the cookie on a custom stack like SvelteKit?

Currently, the Supabase docs set up an expectation of feature parity between SvelteKit and Next.js since Next.js isn't officially endorsed anywhere on the website. However, it was surprising as a user to find that a lot of the login code doesn't directly translate between the two stacks. It's difficult to write custom auth logic without reading the internal code of Supabase packages, which kind of defeats the purpose of using Supabase. Official docs about how Supabase expects your auth logic to be organized would go a long way towards making Supabase (even more!) ergonomic on other stacks.

@silentworks
Copy link
Contributor

Thanks for sharing the auth-helpers repo!

Would it be possible to get official documentation on how to construct, get, and delete the cookie on a custom stack like SvelteKit?

Currently, the Supabase docs set up an expectation of feature parity between SvelteKit and Next.js since Next.js isn't officially endorsed anywhere on the website. However, it was surprising as a user to find that a lot of the login code doesn't directly translate between the two stacks. It's difficult to write custom auth logic without reading the internal code of Supabase packages, which kind of defeats the purpose of using Supabase. Official docs about how Supabase expects your auth logic to be organized would go a long way towards making Supabase (even more!) ergonomic on other stacks.

I will be changing the way how we do this in the auth-helpers project, you will be able to follow from that. But since this isn't library related code as this piece of code doesn't stop you from using this library with SvelteKit I don't think it's an issue.

@J0
Copy link
Contributor

J0 commented Mar 5, 2024

Hey team,

Going to close this issue as it has gone stale. Feel free to re-open / let me know if still relevant though

@J0 J0 closed this as completed Mar 5, 2024
@mayank99
Copy link

mayank99 commented Mar 5, 2024

afaict, the original issue wasn't addressed, but there is now an SSR package for all frameworks https://supabase.com/docs/guides/auth/server-side/email-based-auth-with-pkce-flow-for-ssr?framework=sveltekit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants