Suiii
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. Suiii
locallhost, and also self hosted woking just fine
Recommended threads
- AppwriteException: User (role: guests) m...
Please how do i solve this issue? Below is my code export const createUser = async (username, email, password) => { try { const newAccount = await acco...
- Help with running queries in n8n (self-h...
Hi, I'm trying to query a collection using n8n and Postman. Does anyone have any thoughts on where I am going wrong? Thanks in advance for any help! https://...
- Unable to execute functions in self-host...
Hello there! I am running a custom deployment of appwrite on premise using the docker container. When attempting to deploy a function, the deployment succeeds w...