Back

Error: Adapter 'http' is not available in the build

  • 0
  • Self Hosted
  • Accounts
kstulgys
14 Jun, 2023, 20:41

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 support
Drake
14 Jun, 2023, 20:44

What's the full stack trace?

kstulgys
14 Jun, 2023, 20:52
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)
Drake
14 Jun, 2023, 20:58

Interesting...I think this middleware is running in some edge runtime which is incompatible with our SDK 🧐

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more