Closed xtheonexuk closed 2 months ago
@xtheonexuk, sorry, there's not much for us to go on from this. You'll need to share more of your code for additional help.
Hi Steven
There is no more code - that is all! It's a fresh nextjs project with only a middleware.js file in the root dir #facepalm
@xtheonexuk it seems like this might be a problem with NextJS middlewares and axios. I don't think there's a quick fix for getting the node SDK to work in a NextJS middleware, but can you expand further on what you need to do (I'm assuming your middleware was just a test and you don't actually need to create a user in every request to your app).
@stnguyen90 I've had similar issue with Nuxt on Cloudflare Pages. That's because axios doesn't work on Edge/Workers. A work around is to use node fetch
directly and it worked fine.
A future solution would be to migrate to https://github.com/unjs/ofetch is very tiny and framework agnostic like axios. If you guys are open I can give you a hand implementing ofetch
.
In 1.5, you should be able to use https://github.com/appwrite/sdk-for-node/releases/tag/12.1.0-rc.4 in a NextJS middleware.
👟 Reproduction steps
When I try to use appwrite in NextJS middleware I get the following error...
My middleware.js file is as per the example on https://appwrite.io/docs/getting-started-for-server with my own server variables of course...
My appwrite server is v:1.0.3.501 hosted on digital ocean using the built in docker image - not customised in any way. My local machine is Linux running node v18.11.0 My package.json is as follows...
👍 Expected behavior
Account creation
👎 Actual Behavior
User account not created and error thrown
🎲 Appwrite version
Version 0.10.x
💻 Operating system
Linux
🧱 Your Environment
No response
👀 Have you spent some time to check if this issue has been raised before?
🏢 Have you read the Code of Conduct?