Next.js Middleware does not work with "node-appwrite" because of using the edge runtime
- 0
- Auth
- Web
I use the "node-appwrite" in the Middleware to verify the user session in SSR, in local it works, but when i deploy the project to Vercel, the deployment fail because the Next.js Middleware works in the Edge Runtime, and it does not work with Node.js API, then is not compatible with "node-appwrite".
Any solution to this problem?
The Middleware Code:
export default async function middleware(req: NextRequest) {
const session = await verifySession();
if (!session) return NextResponse.redirect(new URL("/sign-in", req.url));
return NextResponse.next();
}
The Error in the Vercel Console:
Import trace for requested module:
./node_modules/node-appwrite/dist/client.mjs
./node_modules/node-appwrite/dist/index.mjs
A Node.js API is used (process.version at line: 33) which is not supported in the Edge Runtime.
Also, I found the library "react-appwrite", it says that support the Next.js Middleware, this is a proprietary library of AppWrite? or is it created by the community?
Recommended threads
- SSL certificate issuance failed:
Domain verifies but SSL cert fails, tried different subdomains like .api and .aw, used cname and CAA, no prior CAA existed on website, tried Multiple CAAs at on...
- Password check in function
Hi, is there any way now for checking if the users password is correct in a function? I am creating a delete user function and before deleting I would like to c...
- Deployment fails after 15+ minutes: "Wai...
Hi, I'm Jayden. My email is jaydthom@haverford.org, and i'm having persistent deployment failures with my Next.js project. What happens: Push to GitHub trigg...