I have this in my nextjs middleware:
TypeScript
import type { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';
import { Client, Users } from 'node-appwrite';
const usersApiKey = process.env.APPWRITE_USERS_API_KEY!;
const client = new Client()
.setEndpoint(process.env.NEXT_PUBLIC_API_ENDPOINT!)
.setProject(process.env.NEXT_PUBLIC_ENDPOINT!)
.setKey(usersApiKey);
const users = new Users(client);
It build fine but fails on the server : Error: Adapter 'http' is not available in the build
TL;DR
The user is experiencing an error: "Adapter 'http' is not available in the build" in their Next.js middleware. The middleware code includes importing modules and creating instances of 'Client' and 'Users' from 'node-appwrite'. The error occurs during server runtime.
Unfortunately, the support thread does not provide a solution to the error. To address this issue, the user can try the following steps:
1. Check the compatibility of the 'node-appwrite' SDK and the runtime environment.
2. Ensure that the 'http' adapter is available in the build and compatible with the runtime environment.
3. Consult the documentation or supportWhat's the full stack trace?
TypeScript
Error: Adapter 'http' is not available in the build
at Client.call (file:///app/.next/server/src/middleware.js:2215:23)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Users.getPrefs (file:///app/.next/server/src/middleware.js:7520:16)
at async Object.middleware [as handler] (file:///app/.next/server/src/middleware.js:1368:23)
at async adapter (file:///app/.next/server/src/middleware.js:1266:20)
at async runWithTaggedErrors (file:///app/node_modules/next/dist/server/web/sandbox/sandbox.js:94:24)
at async NextNodeServer.runMiddleware (file:///app/node_modules/next/dist/server/next-server.js:1599:24)
at async Object.fn (file:///app/node_modules/next/dist/server/next-server.js:1743:42)
at async Router.execute (file:///app/node_modules/next/dist/server/router.js:315:32)
at async NextNodeServer.runImpl (file:///app/node_modules/next/dist/server/base-server.js:616:29)
Interesting...I think this middleware is running in some edge runtime which is incompatible with our SDK 🧐
Recommended threads
- how to access the value of account statu...
- Redirect from clicking team invite link ...
Hi all! Pretty new to app development in general so this might be something more generic than appwrite, but I've found (after reading the docs for the Teams API...
- Hosting Issues with Static IP not domain...
I have a machine with Static Public IP. I want to host Appwrite Site on it but I tried it but it doesn't allow IP addresses in Domain names. What should I do h...