[GH-ISSUE #31] node-handler mounted incorrectly #25421

Closed
opened 2026-04-17 15:37:13 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @tklein1801 on GitHub (Sep 29, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/31

The node handler throws a HTTP 404 error message for POST requests because it is implemented as a GET endpoint in ExpressJS (as in the documentation).

...
app.get(/api/auth/*, toNodeHandler(auth));
...

The quick and simple attempt to implement the whole thing using app.use failed because the client then always receives the better-call error message with the following content:

[better-call]: Make sure the URL has the basePath (/api/auth).

Translated with DeepL.com (free version)

I haven't quite figured out the logic with better-call yet, so I can't say exactly what a solution might look like.

Originally created by @tklein1801 on GitHub (Sep 29, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/31 The node handler throws a `HTTP 404` error message for POST requests because it is implemented as a GET endpoint in ExpressJS (as in the [documentation](https://www.better-auth.com/docs/integrations/node#mount-the-handler)). ```ts ... app.get(‘/api/auth/*’, toNodeHandler(auth)); ... ``` The quick and simple attempt to implement the whole thing using `app.use` failed because the client then always receives the `better-call` error message with the following content: ``` [better-call]: Make sure the URL has the basePath (/api/auth). ``` Translated with DeepL.com (free version) I haven't quite figured out the logic with `better-call` yet, so I can't say exactly what a solution might look like.
GiteaMirror added the locked label 2026-04-17 15:37:13 -05:00
Author
Owner

@Bekacru commented on GitHub (Sep 29, 2024):

you should use app.all instead

<!-- gh-comment-id:2381468386 --> @Bekacru commented on GitHub (Sep 29, 2024): you should use app.all instead
Author
Owner

@tklein1801 commented on GitHub (Sep 29, 2024):

@Bekacru thank you. I wasn't aware that app.all exists

<!-- gh-comment-id:2381574876 --> @tklein1801 commented on GitHub (Sep 29, 2024): @Bekacru thank you. I wasn't aware that `app.all` exists
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#25421