Basic sign up setup results in 404 for the endpoint "api/auth/sign-up/email" #1011

Closed
opened 2026-03-13 08:17:37 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @SalonLynk on GitHub (Apr 8, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Follow these steps https://www.better-auth.com/docs/installation and I'm using Prisma + Express JS
  2. Call the signup function
authClient.signUp.email({
            email,
            password,
            name
        }, {
            onSuccess: () => {

            },
            onError: (e) => {
                toaster.error({
                    title: e.error.message || ""
                })
            }
        })

Current vs. Expected behavior

Should sign the user up but instead I get 404s

Image

And CORS is configured properly

Image

What version of Better Auth are you using?

^1.2.5

Provide environment information

OS - MacOs

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)

// backend
// .env (BETTER_AUTH_URL=http://localhost:3000)
import {betterAuth} from "better-auth";
import {prismaAdapter} from "better-auth/adapters/prisma";
import {PrismaClient} from "@prisma/client";

const prisma = new PrismaClient();

export const auth = betterAuth({
    emailAndPassword: {
        enabled: true,
        autoSignIn: true,

    },
    database: prismaAdapter(prisma, {
        provider: "postgresql",
    }),
});

// frontend
//.env (VITE_BACKEND_API=http://localhost:3000)

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

const authClientBaseURL = import.meta.env.VITE_BACKEND_API

export const authClient = createAuthClient({
    baseURL: authClientBaseURL
})

Additional context

No response

Originally created by @SalonLynk on GitHub (Apr 8, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Follow these steps https://www.better-auth.com/docs/installation and I'm using Prisma + Express JS 2. Call the signup function ```typescript authClient.signUp.email({ email, password, name }, { onSuccess: () => { }, onError: (e) => { toaster.error({ title: e.error.message || "" }) } }) ``` ### Current vs. Expected behavior Should sign the user up but instead I get 404s <img width="1573" alt="Image" src="https://github.com/user-attachments/assets/4b90fa4c-63e0-4c6c-bc78-3a1b2bf787a6" /> And CORS is configured properly <img width="706" alt="Image" src="https://github.com/user-attachments/assets/b42a61da-a9c7-458c-9d2d-59711896967d" /> ### What version of Better Auth are you using? ^1.2.5 ### Provide environment information ```bash OS - MacOs ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript // backend // .env (BETTER_AUTH_URL=http://localhost:3000) import {betterAuth} from "better-auth"; import {prismaAdapter} from "better-auth/adapters/prisma"; import {PrismaClient} from "@prisma/client"; const prisma = new PrismaClient(); export const auth = betterAuth({ emailAndPassword: { enabled: true, autoSignIn: true, }, database: prismaAdapter(prisma, { provider: "postgresql", }), }); // frontend //.env (VITE_BACKEND_API=http://localhost:3000) import { createAuthClient } from "better-auth/react" const authClientBaseURL = import.meta.env.VITE_BACKEND_API export const authClient = createAuthClient({ baseURL: authClientBaseURL }) ``` ### Additional context _No response_
Author
Owner

@SalonLynk commented on GitHub (Apr 8, 2025):

I made an attempt with cURL and also used the UI from the openAPI and they both had success

Image

However inside React and also inside Postman resulted in a 404

@SalonLynk commented on GitHub (Apr 8, 2025): I made an attempt with cURL and also used the UI from the openAPI and they both had success <img width="1014" alt="Image" src="https://github.com/user-attachments/assets/16bf7d7b-b1ec-4347-a608-852301e09375" /> However inside React and also inside Postman resulted in a 404
Author
Owner

@Kinfe123 commented on GitHub (Apr 9, 2025):

this is the basic cors error. check on this config for your cors - https://www.better-auth.com/docs/integrations/express#cors-configuration

@Kinfe123 commented on GitHub (Apr 9, 2025): this is the basic cors error. check on this config for your cors - https://www.better-auth.com/docs/integrations/express#cors-configuration
Author
Owner

@kainbryanjones commented on GitHub (Apr 9, 2025):

this is the basic cors error. check on this config for your cors - https://www.better-auth.com/docs/integrations/express#cors-configuration

I have followed this guide. There is a screenshot in my post displaying the cors config. It's using env variables for the frontend domains and I have checked. They are valid.

@kainbryanjones commented on GitHub (Apr 9, 2025): > this is the basic cors error. check on this config for your cors - https://www.better-auth.com/docs/integrations/express#cors-configuration I have followed this guide. There is a screenshot in my post displaying the cors config. It's using env variables for the frontend domains and I have checked. They are valid.
Author
Owner

@kainbryanjones commented on GitHub (Apr 9, 2025):

this is the basic cors error. check on this config for your cors - https://www.better-auth.com/docs/integrations/express#cors-configuration

Is it possibly because the call to .use(cors()) is after the app.all() function?

I am away right now and unable to check.

@kainbryanjones commented on GitHub (Apr 9, 2025): > this is the basic cors error. check on this config for your cors - https://www.better-auth.com/docs/integrations/express#cors-configuration Is it possibly because the call to .use(cors()) is after the app.all() function? I am away right now and unable to check.
Author
Owner

@SalonLynk commented on GitHub (Apr 9, 2025):

this is the basic cors error. check on this config for your cors - https://www.better-auth.com/docs/integrations/express#cors-configuration

Is it possibly because the call to .use(cors()) is after the app.all() function?

I am away right now and unable to check.

This was the problem. Also I realise I used 2 different accounts in this post. oops

@SalonLynk commented on GitHub (Apr 9, 2025): > > this is the basic cors error. check on this config for your cors - https://www.better-auth.com/docs/integrations/express#cors-configuration > > Is it possibly because the call to .use(cors()) is after the app.all() function? > > I am away right now and unable to check. This was the problem. Also I realise I used 2 different accounts in this post. oops
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1011