Hi, I'm running a self hosted instance of Appwrite. I have a Next.js app router app where I've implemented registration by following the guide at: https://appwrite.io/docs/tutorials/nextjs-ssr-auth/step-5
I'm running the Next.js app using Docker, and when I try to register I get this error
I investigated the build as well as the docker logs
Docker error logs:
e [Error]: fetch failed
rapidproductshoots-1 | at g.call (/app/.next/server/chunks/913.js:1:2552)
rapidproductshoots-1 | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
rapidproductshoots-1 | at async n.create (/app/.next/server/chunks/913.js:1:13522)
rapidproductshoots-1 | at async x (/app/.next/server/app/register/page.js:1:10131)
rapidproductshoots-1 | at async /app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:406
rapidproductshoots-1 | at async rm (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:15:6342)
rapidproductshoots-1 | at async rq (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:18:1249)
rapidproductshoots-1 | at async doRender (/app/node_modules/next/dist/server/base-server.js:1378:30)
rapidproductshoots-1 | at async cacheEntry.responseCache.get.routeKind (/app/node_modules/next/dist/server/base-server.js:1539:28)
rapidproductshoots-1 | at async NextNodeServer.renderToResponseWithComponentsImpl (/app/node_modules/next/dist/server/base-server.js:1447:28) {
rapidproductshoots-1 | code: undefined,
rapidproductshoots-1 | type: undefined,
rapidproductshoots-1 | response: undefined
rapidproductshoots-1 | }
rapidproductshoots-1 | at async x (/app/.next/server/app/register/page.js:1:10131)
That location contains these lines:
,{account:a}=await (0,l.createAdminClient)();await a.create(c.ID.unique(),t,s,r);let i=await a.createEmailPasswordSession(t,s);
I've also added the hostname correctly to my appwrite project platform
The code itself:
import { getLoggedInUser } from "@/lib/appwrite";
import { redirect } from "next/navigation";
import { ID } from "node-appwrite";
import { createAdminClient } from "@/lib/appwrite";
import { cookies } from "next/headers";
async function signUpWithEmail(formData: any) {
"use server";
const email = formData.get("email");
const password = formData.get("password");
const name = email.split("@")[0];
const { account } = await createAdminClient();
await account.create(ID.unique(), email, password, name);
const session = await account.createEmailPasswordSession(email, password);
cookies().set("my-custom-session", session.secret, {
path: "/",
httpOnly: true,
sameSite: "strict",
secure: true,
});
redirect("/create");
}
export default async function Register() {
const user = await getLoggedInUser();
if (user) redirect("/create");
return (
<form
action={signUpWithEmail}
className=""
>
<input
id="email"
name="email"
placeholder="Email"
type="email"
className=""
/>
<input
id="password"
name="password"
placeholder="Password"
minLength={8}
type="password"
className=""
/>
<button
className=""
type="submit"
>
Get Started
</button>
</form>
);
}
The same error occurs while trying to login as well
The code works fine locally, the issue is for the deployed docker app
Would appreciate any support on this, been stuck for a while 😅
You’ve just posted this 15 minutes ago
Sorry didn't mean to nag, just wanted to add I'd appreciate support. I understand all support is community driven and it may take time for someone to get around to help, or no one might at all. Sorry for the bad phrasing
Just verifying are all your environment variable setup correctly?
Yes, I verified in the build
The NEXTPUBLIC_* API Keys are replaced by the raw strings in the build
and docker exec container env prints out the NEXT_APPWRITE_KEY aswell
Recommended threads
- Github connection error - Self Hosted Ap...
I am trying to connect my github account to deploy a project to sites, but Connect to Gtihub button is disabled. I have configured all Env variables needed for...
- "Domain verification failed"
"Domain verification failed" I was install Appwrite in my VDS server. I using Coolify for install Appwrite. After install complete, i want add my domain, and i ...
- Server Down
Appwrite services are down. When will they start working again?