-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
currentUser is null after registering #1
Comments
Hey @jamauro, thanks for watching the video! Did you add this line to your pb.authStore.loadFromCookie(document.cookie) By default, PocketBase will store the token in local storage. However, the token is not visible to the server. To fix this, we store the token as a cookie instead, which is visible to both the client and server. You should instead check for the presence of a cookie named Let me know if that helps! |
Hmm, it looks like it's only happening in Safari. Chrome works as expected. If I set Do you know of a better way to handle this? |
@jamauro That's a good observation! I will adjust the example accordingly. If we look at SvelteKit's documentation for the Cookie.set() method, it sets Ideally, I'd like to use this method, but PocketBase's Javascript SDK does not give us the raw cookie value, only the serialized cookie value suitable for setting as the The best option is to replicate SvelteKit's options (i.e. setting |
I saw this too, but I'm not sure it's better and I haven't tested it: pocketbase/pocketbase#1490 (reply in thread) |
I have this issue right now. it works in Chrome but not safari. |
Hi; I haven't tested in prod yet, but using // hooks.server.ts
import { dev } from '$app/environment';
// ...
response.headers.append(
'set-cookie',
pb.authStore.exportToCookie({ httpOnly: true, sameSite: 'Lax', secure: dev ? false : true })
);
// ... I'll test in prod when I finally get around to hosting PB somewhere like Fly or the like. Hope it helps. 🙂 |
Hey, thanks for putting together this repo and the YouTube video.
I'm able to successfully register a user but for some reason
$currentUser
is null and when I look at local storage thepocketbase_auth
is{token: '', model: null}
When I console log
pb.authStore.model
inhooks.client.js
, it'snull
Any ideas?
The text was updated successfully, but these errors were encountered: