Convex Auth - /api/auth/ - 404 not found
Getting 404 on client for this API call - http://localhost:3000/api/auth/
Auth type: Phone OTP
auth:signIn action is working and I'm able to get the OTP when running from convex dashboard, so I assume server part is fine.
Client: Next Js
- Wrapped ConvexAuthNextjsServerProvider in RootLayout.
- Wrapped ConvexAuthNextjsProvider in ConvexClientProvider.
Middleware.ts
I'm able to see the output logs
Tried deleting .nextjs and built the client multiple times. No luck.
Network logs:
7 Replies
Do you see any logs in Convex? The middleware should be proxying the
/api/auth
request to Convex so a log line should be showing up there.
The trailing slash seems potentially problematic - you're hitting this when entering in the OTP? If so, mind sharing some of the client code?Getting 404, if I remove the trailing /
No logs in convex. I don't think the request is reaching convex server.
Client code:
Server auth.ts
Some more things to check -- what version of Convex Auth + Convex are you using? (I recommend upgrading to latest if possible)
Are other requests to
localhost:3000
are succeeding (e.g. curl http://localhost:3000
returns something that looks like the HTML for your root page)?
Is there anything else running on port 3000? (on my mac I used lsof -i :3000
and the ps aux | grep <process ID>
to check that the only process on that port was next-server)
Also if you update your version of Convex Auth (0.0.65), there's a verbose
option to convexAuthNextjsMiddleware
that'll hopefully give us more info on what's happening
(convexAuthNextjsMiddleware(handler, { verbose: true })
)Upgraded to latest versions.
path /api/auth/ does not match /api/auth
Next js app is running on 3000I see two requests
1. http://localhost:3000/api/auth - 308 redirect
2. http://localhost:3000/api/auth/ - 404
Looks like trailing slash is causing the issue. Removed trailingSlash: true from the next.config.ts and it seems to be working. Thanks for looking into it.
Ooh nice find -- I'll probably change this to also match the trailing slash (or at a minimum add a note about this next config option)