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
- Does Appwrite allow SSE ?
i'm trying to setup a slack bot on my site. Your deployed SSE endpoint is returning a non‑SSE response …and the browser immediately closes the connection. read...
- The console isnt showing documents
In console ui saved documents are being shown on frontend but i can see its showing 4 or number of docs available but in rows its only showing single doc and th...
- Create a project via REST API or SDK, mi...
I am currently self-hosting Appwrite in my local machine, deployed using docker script in the website. I also installed `appwrite-cli` through npm. I am trying...