better-auth with vite + express #1277

Closed
opened 2026-03-13 08:30:56 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @Sahil-Gupta584 on GitHub (May 28, 2025).

does better-auth supports vite with express? if yes can you please share the doc.
i found one but its uses bun

Originally created by @Sahil-Gupta584 on GitHub (May 28, 2025). does better-auth supports vite with express? if yes can you please share the doc. i found [one](https://catalins.tech/better-auth-with-hono-bun-typescript-react-vite) but its uses bun
Author
Owner

@Sahil-Gupta584 commented on GitHub (May 28, 2025):

ok i found the doc but it doesnt works, i am receving this err

[nodemon] restarting due to changes...
[nodemon] starting `tsx ./src/index.ts`
C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:153
      throw new TypeError(`Missing parameter name at ${i}: ${DEBUG_URL}`);
            ^


TypeError: Missing parameter name at 11: https://git.new/pathToRegexpError
    at name (C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:153:13)
    at lexer (C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:171:21)
    at lexer.next (<anonymous>)
    at Iter.peek (C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:188:32)
    at Iter.tryConsume (C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:195:24)
    at Iter.text (C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:213:26)
    at consume (C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:285:23)
    at parse (C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:320:18)
    at <anonymous> (C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:503:40)
    at Array.map (<anonymous>)

Node.js v22.15.0
[nodemon] app crashed - waiting for file changes before starting...

my code:

import cors from "cors";
import dotenv from "dotenv";
import express from "express";
import { auth } from "./lib/auth.js";

dotenv.config();
const app = express();
app.use(cors({ origin: "http://localhost:5173" }));
app.use(express.json());


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

app.listen(2022, () =>
  console.log("Server is running on http://localhost:2022")
);
@Sahil-Gupta584 commented on GitHub (May 28, 2025): ok i found the [doc](https://www.better-auth.com/docs/installation#mount-handler) but it doesnt works, i am receving this err ``` [nodemon] restarting due to changes... [nodemon] starting `tsx ./src/index.ts` C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:153 throw new TypeError(`Missing parameter name at ${i}: ${DEBUG_URL}`); ^ TypeError: Missing parameter name at 11: https://git.new/pathToRegexpError at name (C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:153:13) at lexer (C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:171:21) at lexer.next (<anonymous>) at Iter.peek (C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:188:32) at Iter.tryConsume (C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:195:24) at Iter.text (C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:213:26) at consume (C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:285:23) at parse (C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:320:18) at <anonymous> (C:\Users\gjugn\Desktop\trt\node_modules\path-to-regexp\src\index.ts:503:40) at Array.map (<anonymous>) Node.js v22.15.0 [nodemon] app crashed - waiting for file changes before starting... ``` my code: ```import { toNodeHandler } from "better-auth/node"; import cors from "cors"; import dotenv from "dotenv"; import express from "express"; import { auth } from "./lib/auth.js"; dotenv.config(); const app = express(); app.use(cors({ origin: "http://localhost:5173" })); app.use(express.json()); app.all("/api/auth/*", toNodeHandler(auth)); app.listen(2022, () => console.log("Server is running on http://localhost:2022") ); ```
Author
Owner

@Sahil-Gupta584 commented on GitHub (May 28, 2025):

https://github.com/expressjs/express/issues/6542#issuecomment-2916833879

@Sahil-Gupta584 commented on GitHub (May 28, 2025): https://github.com/expressjs/express/issues/6542#issuecomment-2916833879
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1277