Web Developer
I'm encountering a persistent "Database not found" error in my Next.js application that uses Appwrite as the backend. Despite following the documentation and checking my configuration, I'm unable to resolve this issue. Below are the details:
Environment:
Next.js (Version: [Your Next.js version])
Appwrite SDK (Version: [Your Appwrite SDK version])
Node.js (Version: [Your Node.js version])
Error Message:
CopyAppwriteException: Database not found
at _Client.call (webpack-internal:///(rsc)/./node_modules/node-appwrite/dist/client.mjs:283:13)
...
code: 404,
type: 'database_not_found',
response: {
message: 'Database not found',
code: 404,
type: 'database_not_found',
version: '1.5.8'
}
Context:
I'm trying to create a user document in my Appwrite database when a new user is created through a third-party authentication service (Dynamic). The error occurs when trying to execute the createDocument method of the Appwrite SDK.
Code Structure:
I have an appwrite.ts file that sets up the Appwrite client:
import { Client, Account, Databases, Users } from "node-appwrite";
export async function createAdminClient() {
const client = new Client()
.setEndpoint(process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT!)
.setProject(process.env.NEXT_PUBLIC_APPWRITE_PROJECT!)
.setKey(process.env.NEXT_APPWRITE_KEY!);
return {
database: new Databases(client),
};
}