404 Error for /api/auth/sign-up

When attempting to access the sign-up endpoint via /api/auth/sign-up/email, the SvelteKit app throws a 404 error:
SvelteKitError: Not found: /api/auth/sign-up/email
at resolve (/home/ubuntu/v2/frontend/node_modules/@sveltejs/kit/src/runtime/server/respond.js:582:13)
at /home/ubuntu/v2/frontend/node_modules/@sveltejs/kit/src/runtime/server/respond.js:370:7
at AsyncLocalStorage.run (node:async_hooks:346:14)
at with_event (/home/ubuntu/v2/frontend/node_modules/@sveltejs/kit/src/runtime/app/server/event.js:49:20)
at resolve (/home/ubuntu/v2/frontend/node_modules/@sveltejs/kit/src/runtime/server/respond.js:369:6)
at svelteKitHandler (file:///home/ubuntu/v2/frontend/node_modules/better-auth/dist/integrations/svelte-kit.mjs:18:10)
at async respond (/home/ubuntu/v2/frontend/node_modules/@sveltejs/kit/src/runtime/server/respond.js:363:20)
at async file:///home/ubuntu/v2/frontend/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:521:22
SvelteKitError: Not found: /api/auth/sign-up/email
at resolve (/home/ubuntu/v2/frontend/node_modules/@sveltejs/kit/src/runtime/server/respond.js:582:13)
at /home/ubuntu/v2/frontend/node_modules/@sveltejs/kit/src/runtime/server/respond.js:370:7
at AsyncLocalStorage.run (node:async_hooks:346:14)
at with_event (/home/ubuntu/v2/frontend/node_modules/@sveltejs/kit/src/runtime/app/server/event.js:49:20)
at resolve (/home/ubuntu/v2/frontend/node_modules/@sveltejs/kit/src/runtime/server/respond.js:369:6)
at svelteKitHandler (file:///home/ubuntu/v2/frontend/node_modules/better-auth/dist/integrations/svelte-kit.mjs:18:10)
at async respond (/home/ubuntu/v2/frontend/node_modules/@sveltejs/kit/src/runtime/server/respond.js:363:20)
at async file:///home/ubuntu/v2/frontend/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:521:22
/home/ubuntu/v2/frontend/src/hooks.server.ts

import { auth } from "$lib/auth";
import { svelteKitHandler } from "better-auth/svelte-kit";

export async function handle({ event, resolve }) {
if (
event.url.pathname.startsWith(
'/.well-known/appspecific/com.chrome.devtools'
)
) {
return new Response(null, { status: 204 }); // Return empty response with 204 No Content
}

return svelteKitHandler({ event, resolve, auth });
}
/home/ubuntu/v2/frontend/src/hooks.server.ts

import { auth } from "$lib/auth";
import { svelteKitHandler } from "better-auth/svelte-kit";

export async function handle({ event, resolve }) {
if (
event.url.pathname.startsWith(
'/.well-known/appspecific/com.chrome.devtools'
)
) {
return new Response(null, { status: 204 }); // Return empty response with 204 No Content
}

return svelteKitHandler({ event, resolve, auth });
}
import { createAuthClient } from "better-auth/svelte"


export const authClient = createAuthClient({
baseURL: "https://sub.domain.de"
});

import { createAuthClient } from "better-auth/svelte"


export const authClient = createAuthClient({
baseURL: "https://sub.domain.de"
});

does anyone have an idea why this happens?
11 Replies
Yannik
YannikOP4mo ago
any idea? @Ping
Ping
Ping4mo ago
Can i see your auth config? @Yannik
Yannik
YannikOP4mo ago
sure @Ping
import { betterAuth } from "better-auth";
import { twoFactor, anonymous, phoneNumber, emailOTP, admin, organization, bearer, captcha, haveIBeenPwned } from "better-auth/plugins"
import { passkey } from "better-auth/plugins/passkey"
import { prismaAdapter } from "better-auth/adapters/prisma";
import prisma from "$lib/server/prisma";


export const auth = betterAuth({
secret: process.env.BETTER_AUTH_SECRET as string,
baseURL: process.env.BETTER_AUTH_URL as string,
database: prismaAdapter(prisma, {
provider: "postgresql",
}),
appName: "AuthClient2025",
plugins: [
twoFactor(),
anonymous(),
phoneNumber({
sendOTP: ({ phoneNumber, code }, request) => {
// Implement sending OTP code via SMS
}
}),
emailOTP({
async sendVerificationOTP({ email, otp, type }) {
// Implement the sendVerificationOTP method to send the OTP to the user's email address
},
}),
passkey(),
admin(),
organization(),
bearer(),
haveIBeenPwned(),
],
emailAndPassword: {
enabled: true
},
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
},
});
import { betterAuth } from "better-auth";
import { twoFactor, anonymous, phoneNumber, emailOTP, admin, organization, bearer, captcha, haveIBeenPwned } from "better-auth/plugins"
import { passkey } from "better-auth/plugins/passkey"
import { prismaAdapter } from "better-auth/adapters/prisma";
import prisma from "$lib/server/prisma";


export const auth = betterAuth({
secret: process.env.BETTER_AUTH_SECRET as string,
baseURL: process.env.BETTER_AUTH_URL as string,
database: prismaAdapter(prisma, {
provider: "postgresql",
}),
appName: "AuthClient2025",
plugins: [
twoFactor(),
anonymous(),
phoneNumber({
sendOTP: ({ phoneNumber, code }, request) => {
// Implement sending OTP code via SMS
}
}),
emailOTP({
async sendVerificationOTP({ email, otp, type }) {
// Implement the sendVerificationOTP method to send the OTP to the user's email address
},
}),
passkey(),
admin(),
organization(),
bearer(),
haveIBeenPwned(),
],
emailAndPassword: {
enabled: true
},
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
},
});
@Ping have you seen this
sabon
sabon3mo ago
@Yannik have you found a solution Because I'm having this exact problen
Hexi
Hexi3mo ago
Fixed: Problem was that he named the hooks.server.ts wrong
Yannik
YannikOP3mo ago
Yes don’t use https Use http
Hexi
Hexi3mo ago
That should not be the issue
Yannik
YannikOP3mo ago
Well that was the case for me
Hexi
Hexi3mo ago
But then you cant use it in production? Or did you just do https://localhost
Yannik
YannikOP3mo ago
Well I did http://domain.de but I wouldn’t recommend that
Domain.de – Domains günstig registrieren – Ihre Domain Suche u...
Domain schnell und günstig registrieren. Freie Domains (.de, .com, .net, .eu, .at, .ch, …) suchen und reservieren. Kostenlos Domains parken und verwalten.
Yannik
YannikOP3mo ago
I haven’t found any other way for using it Lmk if you find any solution

Did you find this page helpful?