[GH-ISSUE #5853] Hitting up signup returns a 404 error #27682

Closed
opened 2026-04-17 18:50:21 -05:00 by GiteaMirror · 17 comments
Owner

Originally created by @idle-user1 on GitHub (Nov 8, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/5853

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

1.Set up backend and email and password authentication
2. Sending request to api/auth/signup returns 404 error

Current vs. Expected behavior

I sent a simple body which contains email, name,password as JSON in postman to /signup endpoint. It gives a 404 error.
the server is up because api/auth/ok returns 200.

Image

server.js ----

Image

/>

i want to get response back after signing up

What version of Better Auth are you using?

1.3.34

System info

{
  "system": {
    "platform": "win32",
    "arch": "x64",
    "version": "Windows 11 Pro",
    "release": "10.0.26100",
    "cpuCount": 12,
    "cpuModel": "AMD Ryzen 5 5600G with Radeon Graphics         ",
    "totalMemory": "13.90 GB",
    "freeMemory": "4.08 GB"
  },
  "node": {
    "version": "v24.11.0",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "11.6.1"
  },
  "frameworks": [
    {
      "name": "express",
      "version": "^5.1.0"
    }
  ],
  "databases": [
    {
      "name": "pg",
      "version": "^8.16.3"
    }
  ],
  "betterAuth": {
    "version": "^1.3.34",
    "config": {
      "database": {
        "_events": {},
        "_eventsCount": 0,
        "options": {
          "user": "postgres",
          "host": "localhost",
          "database": "bok",
          "port": 5432,
          "max": 10,
          "min": 0,
          "maxUses": null,
          "allowExitOnIdle": false,
          "maxLifetimeSeconds": 0,
          "idleTimeoutMillis": 10000
        },
        "_clients": [],
        "_idle": [],
        "_expired": {},
        "_pendingQueue": [],
        "ending": false,
        "ended": false
      },
      "emailAndPassword": {
        "enabled": true
      },
      "providers": {
        "google": {
          "redirectUri": "http://localhost:3000/api/auth/oauth/google/callback"
        }
      }
    }
  }
}

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

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { Pool } from "pg";

export const auth = betterAuth({
  database: new Pool({
    user: "postgres",
    host: "localhost",
    database: "bok",
    password: "********",
    port: 5432,
    // connection options
  }),
  emailAndPassword: {
    enabled: true,
  },
   providers: {
    google: {
      clientId: process.env.GOOGLE_CLIENT_ID,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET,
      redirectUri: "http://localhost:4000/api/auth/oauth/google/callback"
    }
  }
});

Additional context

No response

Originally created by @idle-user1 on GitHub (Nov 8, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/5853 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1.Set up backend and email and password authentication 2. Sending request to api/auth/signup returns 404 error ### Current vs. Expected behavior I sent a simple body which contains email, name,password as JSON in postman to /signup endpoint. It gives a 404 error. the server is up because api/auth/ok returns 200. <img width="1481" height="605" alt="Image" src="https://github.com/user-attachments/assets/c5ea2089-a0fe-4317-8a97-32506240dd7a" /> server.js ---- <img width="738" height="477" alt="Image" src="https://github.com/user-attachments/assets/04859ad7-a859-4e6f-af7d-257d4df30c4e" /> /> i want to get response back after signing up ### What version of Better Auth are you using? 1.3.34 ### System info ```bash { "system": { "platform": "win32", "arch": "x64", "version": "Windows 11 Pro", "release": "10.0.26100", "cpuCount": 12, "cpuModel": "AMD Ryzen 5 5600G with Radeon Graphics ", "totalMemory": "13.90 GB", "freeMemory": "4.08 GB" }, "node": { "version": "v24.11.0", "env": "development" }, "packageManager": { "name": "npm", "version": "11.6.1" }, "frameworks": [ { "name": "express", "version": "^5.1.0" } ], "databases": [ { "name": "pg", "version": "^8.16.3" } ], "betterAuth": { "version": "^1.3.34", "config": { "database": { "_events": {}, "_eventsCount": 0, "options": { "user": "postgres", "host": "localhost", "database": "bok", "port": 5432, "max": 10, "min": 0, "maxUses": null, "allowExitOnIdle": false, "maxLifetimeSeconds": 0, "idleTimeoutMillis": 10000 }, "_clients": [], "_idle": [], "_expired": {}, "_pendingQueue": [], "ending": false, "ended": false }, "emailAndPassword": { "enabled": true }, "providers": { "google": { "redirectUri": "http://localhost:3000/api/auth/oauth/google/callback" } } } } } ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { Pool } from "pg"; export const auth = betterAuth({ database: new Pool({ user: "postgres", host: "localhost", database: "bok", password: "********", port: 5432, // connection options }), emailAndPassword: { enabled: true, }, providers: { google: { clientId: process.env.GOOGLE_CLIENT_ID, clientSecret: process.env.GOOGLE_CLIENT_SECRET, redirectUri: "http://localhost:4000/api/auth/oauth/google/callback" } } }); ``` ### Additional context _No response_
GiteaMirror added the locked label 2026-04-17 18:50:21 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Nov 8, 2025):

Hi there! It looks like the signup route is returning a 404 error, which usually indicates that the endpoint you’re trying to access isn’t correctly mounted. In Better Auth, the routes—including the one for signup—are typically mounted under a base path (by default it might be something like /api/auth/ or /auth/api depending on how you configure your server). Please double-check the following:

• Verify that your Express app is correctly mounting the Better Auth routes. For example, if your auth middleware is set up to register routes under a specific base path, you’ll need to make sure your POST request is sent to that exact URL rather than just /signup.
• Ensure the POST request includes the correct JSON body (email, name, password) as expected by Better Auth.
• Review your auth configuration to see if a custom basePath is set. If you haven’t defined one, the default might differ from what you’re hitting with your request.

Our Basic Usage documentation shows how to properly set up and utilize these endpoints, and following that pattern should resolve the 404 issue [1].

Tag @better-auth-agent if you would like an answer from the Agent.

Would you like more details on how to adjust your server routing or any further troubleshooting tips?

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3506627784 --> @better-auth-agent[bot] commented on GitHub (Nov 8, 2025): Hi there! It looks like the signup route is returning a 404 error, which usually indicates that the endpoint you’re trying to access isn’t correctly mounted. In Better Auth, the routes—including the one for signup—are typically mounted under a base path (by default it might be something like /api/auth/ or /auth/api depending on how you configure your server). Please double-check the following: • Verify that your Express app is correctly mounting the Better Auth routes. For example, if your auth middleware is set up to register routes under a specific base path, you’ll need to make sure your POST request is sent to that exact URL rather than just /signup. • Ensure the POST request includes the correct JSON body (email, name, password) as expected by Better Auth. • Review your auth configuration to see if a custom basePath is set. If you haven’t defined one, the default might differ from what you’re hitting with your request. Our Basic Usage documentation shows how to properly set up and utilize these endpoints, and following that pattern should resolve the 404 issue [[1]](https://github.com/better-auth/better-auth/issues/4125). Tag @better-auth-agent if you would like an answer from the Agent. Would you like more details on how to adjust your server routing or any further troubleshooting tips? <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

@idle-user1 commented on GitHub (Nov 8, 2025):

@better-auth-agent Still is not working, help

<!-- gh-comment-id:3506637381 --> @idle-user1 commented on GitHub (Nov 8, 2025): @better-auth-agent Still is not working, help
Author
Owner

@better-auth-agent[bot] commented on GitHub (Nov 8, 2025):

It looks like your Better Auth signup endpoint isn’t being reached. A common cause for this is that the Better Auth router isn’t mounted correctly on your Express app. Make sure you have something like:

  app.use("/api/auth", auth.router);

in your server setup so that POST requests to /api/auth/signup are properly handled [1]. Also, double-check that you’re sending the request with the correct HTTP method (POST) and with the required JSON body (email, name, password) as expected by the framework [2]. Could you verify that the router is properly registered and that the request method and headers match what Better Auth expects?
tag @better-auth-agent if you would like an answer from the Agent

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3506637904 --> @better-auth-agent[bot] commented on GitHub (Nov 8, 2025): It looks like your Better Auth signup endpoint isn’t being reached. A common cause for this is that the Better Auth router isn’t mounted correctly on your Express app. Make sure you have something like:   app.use("/api/auth", auth.router); in your server setup so that POST requests to /api/auth/signup are properly handled [[1]](https://github.com/better-auth/better-auth/issues/4125). Also, double-check that you’re sending the request with the correct HTTP method (POST) and with the required JSON body (email, name, password) as expected by the framework [[2]](https://github.com/better-auth/better-auth/issues/917). Could you verify that the router is properly registered and that the request method and headers match what Better Auth expects? tag @better-auth-agent if you would like an answer from the Agent <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

@idle-user1 commented on GitHub (Nov 8, 2025):

import express from "express";
import { toNodeHandler } from "better-auth/node";
import { auth } from "./auth.js";
import cors from "cors";
const app = express()

const port = 4000;

app.all("/api/auth/*splat", toNodeHandler(auth));

// Mount express json middleware after Better Auth handler
// or only apply it to routes that don't interact with Better Auth
app.use(express.json());

app.listen(port, () => {
console.log(Better Auth app listening on port ${port});
});

@better-auth-agent i dont need to mount auth router im direclty using it in server.js.
Yes im using the current http method
Do i need to send headers with my request? if so what headers

<!-- gh-comment-id:3506640900 --> @idle-user1 commented on GitHub (Nov 8, 2025): import express from "express"; import { toNodeHandler } from "better-auth/node"; import { auth } from "./auth.js"; import cors from "cors"; const app = express() const port = 4000; app.all("/api/auth/*splat", toNodeHandler(auth)); // Mount express json middleware after Better Auth handler // or only apply it to routes that don't interact with Better Auth app.use(express.json()); app.listen(port, () => { console.log(`Better Auth app listening on port ${port}`); }); @better-auth-agent i dont need to mount auth router im direclty using it in server.js. Yes im using the current http method Do i need to send headers with my request? if so what headers
Author
Owner

@better-auth-agent[bot] commented on GitHub (Nov 8, 2025):

Hi there! For the email signup endpoint, you should include the standard JSON headers—specifically, set "Content-Type: application/json" (and optionally "Accept: application/json") to ensure that Better Auth correctly parses the request payload. This header is required so that the JSON body (with keys like email, name, and password) is properly recognized during the request. Also, please confirm that you’re sending your request using the POST method to the /api/auth/signup endpoint. Could you try this and let us know if it resolves the 404 error? Tag @better-auth-agent if you would like an answer from the Agent.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3506641125 --> @better-auth-agent[bot] commented on GitHub (Nov 8, 2025): Hi there! For the email signup endpoint, you should include the standard JSON headers—specifically, set "Content-Type: application/json" (and optionally "Accept: application/json") to ensure that Better Auth correctly parses the request payload. This header is required so that the JSON body (with keys like email, name, and password) is properly recognized during the request. Also, please confirm that you’re sending your request using the POST method to the /api/auth/signup endpoint. Could you try this and let us know if it resolves the 404 error? Tag @better-auth-agent if you would like an answer from the Agent. <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

@idle-user1 commented on GitHub (Nov 8, 2025):

@better-auth-agent.Yes im sending the correct headers and yes im using POST method. the issue still persists

<!-- gh-comment-id:3506644308 --> @idle-user1 commented on GitHub (Nov 8, 2025): @better-auth-agent.Yes im sending the correct headers and yes im using POST method. the issue still persists
Author
Owner

@better-auth-agent[bot] commented on GitHub (Nov 8, 2025):

It sounds like your Better Auth endpoints may not be mounted as you expect. In many setups the auth API is mounted under a specific base path (for example, /api/auth), so double-check that in your express configuration you’re using something like:

  app.use("/api/auth", auth.api);

This ensures that the signup endpoint is available at /api/auth/signup rather than just /signup. Also confirm that your server file is correctly importing and using the auth routes. If you’re still encountering issues, it might help to verify that your Better Auth configuration (including any custom basePath, if set) matches your request URL.

Could you please review your route mounting and ensure the signup URL is correct? Tag @bekacru or @ping__ if you need further assistance. Tag @better-auth-agent if you would like an answer from the Agent.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3506644555 --> @better-auth-agent[bot] commented on GitHub (Nov 8, 2025): It sounds like your Better Auth endpoints may not be mounted as you expect. In many setups the auth API is mounted under a specific base path (for example, /api/auth), so double-check that in your express configuration you’re using something like:   app.use("/api/auth", auth.api); This ensures that the signup endpoint is available at /api/auth/signup rather than just /signup. Also confirm that your server file is correctly importing and using the auth routes. If you’re still encountering issues, it might help to verify that your Better Auth configuration (including any custom basePath, if set) matches your request URL. Could you please review your route mounting and ensure the signup URL is correct? Tag @bekacru or @ping__ if you need further assistance. Tag @better-auth-agent if you would like an answer from the Agent. <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) • [Discord](https://discord.gg/better-auth) • [GitHub](https://github.com/better-auth/better-auth) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/better-auth_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/better-auth) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/better-auth/better-auth)
Author
Owner

@idle-user1 commented on GitHub (Nov 8, 2025):

@Bekacru Yes i have reviewed it and i cant find a solution. I need assistance

<!-- gh-comment-id:3506650141 --> @idle-user1 commented on GitHub (Nov 8, 2025): @Bekacru Yes i have reviewed it and i cant find a solution. I need assistance
Author
Owner

@alexvarney commented on GitHub (Nov 9, 2025):

+1, I also ran into this issue a couple days ago trying to set up better-auth in a fastify project and following the guide. I also tried setting it up in a Hono project and encountered the same issue.

<!-- gh-comment-id:3508906631 --> @alexvarney commented on GitHub (Nov 9, 2025): +1, I also ran into this issue a couple days ago trying to set up better-auth in a fastify project and following the guide. I also tried setting it up in a Hono project and encountered the same issue.
Author
Owner

@rovertrack commented on GitHub (Nov 12, 2025):

hit this endpoint

`
http://localhost:4000/api/auth/sign-up/email

`
if it returns origin error , for dev mode use

advanced:{
        disableCSRFCheck:true,
        disableOriginCheck:true,
    },
<!-- gh-comment-id:3522333698 --> @rovertrack commented on GitHub (Nov 12, 2025): hit this endpoint ` http://localhost:4000/api/auth/sign-up/email ` if it returns origin error , for dev mode use ``` advanced:{ disableCSRFCheck:true, disableOriginCheck:true, }, ```
Author
Owner

@adriangalilea commented on GitHub (Nov 20, 2025):

Same issue here,

hit this endpoint

` http://localhost:4000/api/auth/sign-up/email

` if it returns origin error , for dev mode use

advanced:{
        disableCSRFCheck:true,
        disableOriginCheck:true,
    },

this seems insecure

<!-- gh-comment-id:3559367912 --> @adriangalilea commented on GitHub (Nov 20, 2025): Same issue here, > hit this endpoint > > ` http://localhost:4000/api/auth/sign-up/email > > ` if it returns origin error , for dev mode use > > ``` > advanced:{ > disableCSRFCheck:true, > disableOriginCheck:true, > }, > ``` this seems insecure
Author
Owner

@rovertrack commented on GitHub (Nov 20, 2025):

Same issue here,

hit this endpoint
http://localhost:4000/api/auth/sign-up/email if it returns origin error , for dev mode use

advanced:{
        disableCSRFCheck:true,
        disableOriginCheck:true,
    },

this seems insecure

That is only to check if it's working in dev mode 😅

<!-- gh-comment-id:3559379545 --> @rovertrack commented on GitHub (Nov 20, 2025): > Same issue here, > > > hit this endpoint > > ` http://localhost:4000/api/auth/sign-up/email > > ` if it returns origin error , for dev mode use > > ``` > > advanced:{ > > disableCSRFCheck:true, > > disableOriginCheck:true, > > }, > > ``` > > this seems insecure That is only to check if it's working in dev mode 😅
Author
Owner

@Bekacru commented on GitHub (Nov 20, 2025):

Have you set BETTER_AUTH_URL

<!-- gh-comment-id:3559439709 --> @Bekacru commented on GitHub (Nov 20, 2025): Have you set `BETTER_AUTH_URL`
Author
Owner

@adriangalilea commented on GitHub (Nov 20, 2025):

Woah, it turned out to be that for whatever reason I had to “make public” the github app in advanced settings so it could be installed on other accounts.

I had this app running for a year and a half without issues, they seem to have changed something recently, the moment it was public signups work well.

<!-- gh-comment-id:3559462711 --> @adriangalilea commented on GitHub (Nov 20, 2025): Woah, it turned out to be that for whatever reason I had to “make public” the github app in advanced settings so it could be installed on other accounts. I had this app running for a year and a half without issues, they seem to have changed something recently, the moment it was public signups work well.
Author
Owner

@mszulfiqar commented on GitHub (Nov 21, 2025):

should try this (worked for me):
app.all("/api/auth/{*splat}", toNodeHandler(auth));

instead of:
app.all("/api/auth/*splat", toNodeHandler(auth));

<!-- gh-comment-id:3563787021 --> @mszulfiqar commented on GitHub (Nov 21, 2025): should try this (worked for me): app.all("/api/auth/{*splat}", toNodeHandler(auth)); instead of: app.all("/api/auth/*splat", toNodeHandler(auth));
Author
Owner

@ping-maxwell commented on GitHub (Nov 22, 2025):

@idle-user1 the correct endpoint is /api/auth/sign-up/email not /api/auth/signup

<!-- gh-comment-id:3566907884 --> @ping-maxwell commented on GitHub (Nov 22, 2025): @idle-user1 the correct endpoint is `/api/auth/sign-up/email` not `/api/auth/signup`
Author
Owner

@Antardas commented on GitHub (Jan 22, 2026):

In my case, I used it as app.use(); it should be app.all()

<!-- gh-comment-id:3784125480 --> @Antardas commented on GitHub (Jan 22, 2026): In my case, I used it as `app.use();` it should be `app.all()`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#27682