
Hi guys, can i check if i'm planning to use middleware.ts i'm supposed to use node-appwrite
right? I'm using just the appwrite
one and it doesn't seem to work.
Keeps saying i'm not authenticated while i already am

In addition i've tried
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
import { appwriteServerAccount } from './lib/server/appwriteServer'
export async function middleware(request: NextRequest) {
if (request.nextUrl.pathname.startsWith('/dashboard')) {
const user = await appwriteServerAccount.get();
console.log(user)
if (!user) {
return NextResponse.redirect(new URL('/login', request.url))
}
}
return NextResponse.next()
}
export const config = {
matcher: ['/dashboard/:path*'],
}
and
import { Account } from 'node-appwrite';
import { Client } from 'node-appwrite';
const appwriteServerClient = new Client();
appwriteServerClient
.setEndpoint(process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT as string)
.setProject(process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID as string)
.setKey(process.env.APPWRITE_SECRET_API_KEY as string);
export const appwriteServerAccount = new Account(appwriteServerClient);
export default appwriteServerClient;
But it still says i'm not authenticated
Recommended threads
- Sharing cookies
Hi, I’m using Appwrite Cloud, and I have a setup where my Appwrite backend is hosted on a subdomain (e.g., api.example.com), while my frontend (Next.js app) and...
- Custom Domain Issue
i have added a custom domain about 21 hours ago, but till now there is no SSL certificate is active on it. but if i do DNS check via https://dnschecker.org/#C...
- Flutter OAuth2 Google does not return to...
When the flow starts, the browser opens, I select an account, and it keeps showing: """ Page not found The page you're looking for doesn't exist. `general_rout...
