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
- Self-host migration from 1.8.X
Is it safe to now migrate from 1.7.4 to 1.8.X on my selfhost?
- DeploymentStatus enum value `canceled` m...
Hey, Sorry if it has been reported already, I found an issue using the Dart SDK where the `canceled` enum value is missing from `DeploymentStatus`. This causes...
- Flutter OAuth2 webAuth Bug?
I created with flutter an app where I can login in with my Microsoft Account. When I compile it to Web (WASM) or Android (aab) then there is no problem what so ...