-
Notifications
You must be signed in to change notification settings - Fork 240
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
Passing variables to createClient
constructor in Next.js
#1229
Comments
Hey @azivkovi, thanks for the message! We're working on more docs that will be complete on, or shortly after, our Comments launch (it's still in private beta) 🙂 Setting a cookie, right! We'd recommend using a |
Thank you for the info @CTNicholas. The docs are really well done and we did get the app running in a couple of days. It was just this one thing I was wondering if there is a better way than what we do. This is our auth setup in const client = createClient({
authEndpoint: async (room) => {
const response = await fetch('/api/v1/liveblocks/auth', {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: process.env.API_KEY },
body: JSON.stringify({ room }),
});
return await response.json();
},
}); The auth endpoint reads the cookie containing userId and gets the user from db. This is just for single user auth. We set the cookie just for this purpose, but I was wondering if it was possible for authEndpoint to get the userId right here in |
Thank you for the kind words @azivkovi! Okay, thanks for the info on your setup!
Do you mean like this?
This actually isn't possible! Did you mean you'd like |
I was thinking of having the If that isn't possible I guess the only way for the auth endpoint to get the |
Hello, it would be helpful to me having a more specific example on how to fetch users data in
liveblocks.config.js
.From the docs currently:
The config file is in the root of the project and I can't read session or context in order to get
userIds
using hooks. The only way I got it to work is setting a cookie specially for this purpose containing userId and then reading it on theauthEndpoint
.This is the docs page:
Ex. https://liveblocks.io/docs/api-reference/liveblocks-react
Thank you.
The text was updated successfully, but these errors were encountered: