TypeScript
// function to get session.
export async function auth() {
try {
const cookieStore = await cookies()
const sessionCookie = cookieStore.get("appwrite-session")
if (!sessionCookie) {
log.info("No session cookie found")
return null
}
const { account } = await createSessionClient()
return await account.get()
} catch (error) {
console.error("Error during authentication:", error)
return null
}
}
TL;DR
Developers are trying to access session inside 'middleware.ts' but facing difficulties. They mention that the application works fine on 'localhost' and 'self-hosted' setups. The provided code snippet shows an 'auth' function that tries to retrieve a session cookie but encounters issues.
Solution: Check if the cookieStore.get("appwrite-session") is returning the session correctly. Make sure that the session is properly set up and accessible within the middleware. Double-check the middleware configuration and ensure the cookie is being passed correctly for session retrieval.locallhost, and also self hosted woking just fine
Recommended threads
- Sudden CORS Errors - Domain hasn't Chang...
I have an Appwrite project with two web apps configured, the first one has the hostname `*` and the second one I just added to test if it could fix the issue wi...
- User ID case sensitivity
I see that through REST (and SDK as well), getting a user is not case sensitive. And even though documentation does not clearly state that it is, the wording "V...
- Any way to temporarily bypass the email ...
Hey guys, any way to bypass the email verification to use the accounts again? i need to recover some projects that due to recent changes have been stopped, and ...