Well yeah it only shows how to run it
The how does it work explains how it works:
https://github.com/Meldiron/appwrite-ssr-next-js/#-so-how-does-it-work
Well yeah but more about how I can implement it tbh so I would need to make a API endpoint that will save the user data?
Well like this
But is there a example code with only the core things because I cannot see it in the code instantly...
Because I have found this so basically set the cookies to the main website but to my understanding you still need to fetch the username right?
The repo has all the codes.
ah it sets it in the cookies after it fetched the data
makes sense
And then future requests pulls the data out of the cookie: https://github.com/Meldiron/appwrite-ssr-next-js/blob/32cbcd586be3d63423d8bfc7a3a7e958dad00eba/src/app/page.tsx#L8
alr will make my own version of that then <a:happi:1107928866477064202>
With some copy pasting
[SOLVED] nextJS SSR
nextJS SSR
Quick question how can I retrieve the jwt token so the token to store to get access to the api endpoint
Appwrite uses cookies which is why there's this: https://github.com/Meldiron/appwrite-ssr-next-js/blob/32cbcd586be3d63423d8bfc7a3a7e958dad00eba/src/app/api/login/route.ts#L39
So like:
const response = await fetch(
`${AppwriteEndpoint}/account/sessions`,
{
method: "POST",
headers: {
"x-appwrite-project": AppwriteProject,
},
}
);
const json = await response.json();
const cookiesStr = (response.headers.get("set-cookie") ?? "")
.split(appwriteHostname)
.join(ssrHostname);
``` And this will return the cookies?
because that return with null so I am probably doing something wrong
Did you set the domains up like the readme described?
I did this
export default async function handler(req, res) {
const response = await fetch(
process.env.APPWRITE_URL + `/v1/account/sessions`,
{
method: "POST",
headers: {
"x-appwrite-project": process.env.APPWRITE_PROJECT,
},
}
);
const cookiesStr = (response.headers.get("set-cookie") ?? "")
.split(process.env.APPWRITE_URL)
.join(process.env.NEXTAUTH_URL);
return res
.status(200)
.json({ success: true, info: response.headers.get("set-cookie") });
}
The actual hostnames of your app and Appwrite matter
oh nvm I get it now so put appwrite to process.env.NEXTAUTH_URL
To ensure server-side rendering works, we need to set those cookies on our SSR server hostname instead of the Appwrite hostname. Let's say our Appwrite instance is on cloud.appwrite.io, and our app is on myapp.com. SSR server on domain myapp.com won't receive appwrite.io cookies. This is expected behavior, as browsers keep 1st party cookies securely scoped to specific domains.
[SOLVED] nextJS SSR
Recommended threads
- Bulk feature status
Hi there, I am using version 1.7.4 self hosted and wanted to use the bulk operations in a dart function. I saw that in the dart_appwrite sdk version 16.1.0 it ...
- Auto Updating Backend & Auth via Appwrit...
<@870607367597850624> Hey everyone ๐ I wanted to ask to ask for a friend, heโs asking if Appwrite be used in a similar way to Supabase when integrated with AI ...
- execution failed
When executing an appwrite function, I'm getting a 500 error, but I don't see it in executions. This issue appeared today. Here's the appwrite function ID: 68b4...