fix: lazy env var check in server.ts — prevent module-level throw during Docker build
This commit is contained in:
@@ -11,23 +11,21 @@ import {
|
||||
Users,
|
||||
} from "node-appwrite";
|
||||
|
||||
const endpoint = process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT;
|
||||
const projectId = process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID;
|
||||
const apiKey = process.env.APPWRITE_API_KEY;
|
||||
|
||||
if (!endpoint || !projectId) {
|
||||
throw new Error(
|
||||
"Missing NEXT_PUBLIC_APPWRITE_ENDPOINT or NEXT_PUBLIC_APPWRITE_PROJECT_ID. Check .env.local.",
|
||||
);
|
||||
}
|
||||
|
||||
export const APPWRITE_SESSION_COOKIE = "isletmem-session";
|
||||
|
||||
function baseClient() {
|
||||
return new Client().setEndpoint(endpoint!).setProject(projectId!);
|
||||
const endpoint = process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT;
|
||||
const projectId = process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID;
|
||||
if (!endpoint || !projectId) {
|
||||
throw new Error(
|
||||
"Missing NEXT_PUBLIC_APPWRITE_ENDPOINT or NEXT_PUBLIC_APPWRITE_PROJECT_ID.",
|
||||
);
|
||||
}
|
||||
return new Client().setEndpoint(endpoint).setProject(projectId);
|
||||
}
|
||||
|
||||
export function createAdminClient() {
|
||||
const apiKey = process.env.APPWRITE_API_KEY;
|
||||
if (!apiKey) {
|
||||
throw new Error("Missing APPWRITE_API_KEY. Required for admin operations.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user