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
- Self-Hosted and Multi Region support
Hey Appwrite Team, As a test and to expand self-hosted capabilities even more, i was thinking of understanding and testing how to deploy a multi-region instanc...
- Auth not working
guys my appwrite auth isnt working? oauth works (Sign in with google n discord) i have 2 websites deployed where do i get help when i do sign in with email and ...
- How to use dart workspaces to deploy a f...
Hello, I'm developing a Flutter application and I would like to leverage dart pub workspaces to deploy a function with a dart runtime as advertised here : http...