Closed y471n closed 3 months ago
Start a new pull request in StackBlitz Codeflow.
Supabase puts by default in the LocalStorage the authentication information, how I solved it was by creating a hook that gets that localStorage and then set it as a cookie in the path.
@kokecar11 Can you share an example of that?
Any news on this issue? @kokecar11 can you share your solution pls?
import { type Cookie } from '@builder.io/qwik-city';
import { createServerClient as _createServerClient, type CookieOptions } from '@supabase/ssr';
export const createServerClient = (headers: Headers, cookie: Cookie, next: { (): Promise<void>; }) => {
return _createServerClient(
import.meta.env.PUBLIC_SUPABASE_URL!,
import.meta.env.PUBLIC_SUPABASE_ANON_KEY!,
{
cookies: {
get(key: string) {
return cookie.get(key)?.value
},
async set(key: string, value: string, options: CookieOptions) {
try {
cookie.set(
key,
value,
{ ...options },
)
headers.set(
key,
value
)
} catch (error) {
console.log(error)
} finally {
await next();
}
},
async remove(key: string, options: CookieOptions) {
try {
cookie.delete(
key,
{ ...options },
)
headers.delete(key)
} catch (error) {
console.log(error)
} finally {
await next();
}
},
},
}
)
}
Thanks @C0DE-IN for sharing your solution. @y471n I'm closing this one because we have a solution, feel free to open a new issue if it's still an issue for you. Thanks
Which component is affected?
Qwik Runtime
Describe the bug
From Supabase after login, I get redirected to
http://localhost:5173/#access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpX...
There are 2 issues in this.
#
via theuseLocation
hook. I can see in console the following object:Reproduction
https://stackblitz.com/edit/qwik-starter-r4xto2?file=src%2Froutes%2Findex.tsx
Steps to reproduce
No response
System Info
Additional Information
The first part of the issue isn't reproduced on StackBlitz but there's an ongoing related discussion to it on Qwik Discord at: https://discord.com/channels/842438759945601056/1111605183483482162/1111605183483482162