
I am trying to make a registration flow for the next.js using node-appwriter sdk as SSR. I am trying to add email verification but isn't working giving some errors:
(role: application) missing scope account
I have gave all the scope permissions in the API. Then too getting this error. Anyone know then it will be great full.
My current register user code looks like:
"use server";
import { createAdminClient } from "@/lib/appwrite";
import { RegisterFormData, registerSchema } from "@/schemas/register";
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
import { AppwriteException, ID } from "node-appwrite";
export async function registerUser(data: RegisterFormData) {
const validatedData = registerSchema.safeParse(data);
if (!validatedData.success) {
return {
success: false,
errors: validatedData.error.errors.map((error) => ({
field: error.path.join("."),
message: error.message,
})),
}
}
const { fullName, email, password } = validatedData.data;
const { account } = await createAdminClient();
try {
await account.create(ID.unique(), email, password, fullName);
const session = await account.createEmailPasswordSession(email, password);
const cookieStore = await cookies();
cookieStore.set("custom-auth-session", session.secret, {
path: "/",
httpOnly: true,
sameSite: "strict",
secure: true,
});
await account.createVerification("http://rnhyg-2409-40c1-3085-5d34-d518-3aa8-c6ca-460d.a.free.pinggy.link/auth/verify-email");
redirect("/verify-email");
} catch (error) {
if (error instanceof AppwriteException) {
const response = JSON.parse(error.response ?? '{}') ?? {};
return {
success: false,
errors: [{ field: "general", message: response.message }],
};
} else {
return {
success: false,
errors: [{ field: "general", message: "An unexpected error occurred" }],
};
}
}
}
Recommended threads
- Vite build permission failed
im trying to deploy a react site using appwrite sites and it keeps failing to build ```2025-08-10T20:20:15.168371867Z [20:20:15] [open-runtimes] Environment pr...
- How to proper delete a serverless functi...
I tried `appwrite functions delete --function-id 12345`, it deletes the online one, but even after trying `appwrite pull functions`, the local one in the appwri...
- Do I have to manually change the endpoin...
The CLI never changes the json file, for example: ```bash appwrite client --endpoint https://url --project-id my-project --key standard_12345 ```` I do not k...
