-
-
Notifications
You must be signed in to change notification settings - Fork 494
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What version of Elysia is running?
1.4.27
What platform is your computer?
Darwin 25.4.0 arm64 arm
What environment are you using
Bun 1.3.10
Are you using dynamic mode?
No - new Elysia({ aot: true })
What steps can reproduce the bug?
- Create a global Elysia app and mount services using the service pattern.
import { Elysia } from "elysia";
import { api } from "./services/api";
const app = new Elysia()
.use(api)
.listen(3000);- Create an API service with the
/apiprefix.
import { Elysia } from "elysia";
import { auth } from "../auth";
export const api = new Elysia({ prefix: "/api" })
.mount(auth.handler);- Configure Better Auth with:
basePath: "/api/auth"-
Start the server.
-
Call authentication endpoints.
Working endpoints:
POST /api/auth/sign-up/email
POST /api/auth/sign-in/email
These work correctly.
- Try accessing the dashboard route:
/api/auth/dash/*
Result:
404 Not Found
- If routes are defined explicitly instead of using
mount:
export const api = new Elysia({ prefix: "/api" })
.get("/auth/*", async ({ request }) => auth.handler(request))
.post("/auth/*", async ({ request }) => auth.handler(request));Then the dashboard routes work correctly:
/api/auth/dash/*
What is the expected behavior?
Expected behavior
Mounting the Better Auth handler in Elysia should expose all auth routes correctly.
With:
export const api = new Elysia({ prefix: "/api" })
.mount(auth.handler);and:
basePath: "/api/auth"all routes should work, including:
/api/auth/sign-in
/api/auth/sign-up
/api/auth/session
/api/auth/dash/*
The behavior should match the manual routing approach using .get("/auth/*") and .post("/auth/*"), without returning 404 for dashboard routes.
What do you see instead?
18:49:17.107 IST GET /api/auth/dash/list-users 404 Not Found
18:49:17.334 IST GET /api/auth/dash/config 404 Not Found
18:49:16.767 IST GET /api/auth/dash/user-graph-data 404 Not Found
Additional information
No response
Have you try removing the node_modules and bun.lockb and try again yet?
Yes
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working