
Hello everyone,
I am trying to use a middleware to protect some routes on my NextJS project.
I am running into an error. Could someone help me understand what it means ?
NB : I am using appwrite 1.5 (self-hosted)
edit: typo

I found the following in the NextJS documentation :
"Middleware currently only supports the Edge runtime. The Node.js runtime can not be used."
So "import { Client, Account } from "node-appwrite"; is probably the issue here.
What do you think about just checking if there is a cookie ?
Probably the worst idea ever right ? Because everyone could just generate a custom cookie... Right ?
Soooo basically, I am f***ed and need to wait for Node.js runtime support by NextJS for middleware ?

This is a known issue for the SDK, and I'm fairly sure they're working on a fix to see if they can polyfill to allow it to be used for Edge runtime. For my project using this, I do just check if a cookie is set and then do the auth checks in a layout instead until I'm able to move it to middleware.
https://github.com/appwrite/sdk-generator/pull/795 https://github.com/appwrite/sdk-generator/pull/799

Thanks Ryan for your time and your answer.
I will follow this closely. ❤️
Recommended threads
- Domain not working
My domain [fork-fable.appwrite.network](https://fork-fable.appwrite.network/) returns a 500 even after deleting and redeploying. Other domains added in domains ...
- File tokens regenerate each page reload
Hello, on appwrite 1.7.4, when I create a file token via the API Tokens(appwriteAdminClient)#createFileToken I get a secret, then when I check in the console t...
- CSV Import Shows Success but Data Not Ap...
I tried importing a CSV file into my PRODUCTS collection. The dashboard shows the message “Import to PRODUCTS completed successfully,” but no data appears in th...
