ILYES DRAGOVIC
ILYES DRAGOVIC13h ago

OAuth works but redirects to Convex domain with “No matching routes found” instead of frontend

I’ve been setting up OAuth with @convex-dev/auth (Google + GitHub). The login flow does work — users are created in the Convex users table and show up in the dashboard. The problem is after authentication: instead of redirecting back to my frontend app (running on http://localhost:3000 in dev), the browser gets stuck on the Convex backend domain (https://grandiose-meadowlark-398.convex.site) and shows only: No matching routes found The network tab shows errors like: GET https://grandiose-meadowlark-398.convex.site/?code=14452581 404 (Not Found) So Convex successfully authenticates the user but does not forward them back to my frontend app. I tried setting redirectTo in signIn and also experimented with SITE_URL, but I keep running into errors like: Invalid redirectTo http://localhost:3000 for configured SITE_URL: https://grandiose-meadowlark-398.convex.site In short: Users are stored correctly in Convex. After login, Convex leaves me on the backend domain with “No matching routes found.” It never redirects to my frontend app. How should I configure this properly so Convex redirects back to my frontend instead of leaving the browser at .convex.site? Thank you for your time, I would appreciate a help here
18 Replies
Convex Bot
Convex Bot13h ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
Sara
Sara13h ago
Have you made sure to add the callback urls in your github and google? what you can do is in the SignIn function, pass a variable called "reditectTo" which redrects after correct sign in or add that in your middleware! does this solve your problem?
ILYES DRAGOVIC
ILYES DRAGOVICOP12h ago
Hey @Sara thank you for you reply I made sure the callback urls are set correctly , I followed from the convex doc I also added the redirectTo in the signIn functions I also tried adding to the src\middleware.ts , and the problem remains even after I restarted both front-end and convex servers I still get No matching routes found
No description
No description
No description
No description
Sara
Sara12h ago
that;s not how you use the middleware..
ILYES DRAGOVIC
ILYES DRAGOVICOP12h ago
it used to be like this : // src/middleware.ts import { convexAuthNextjsMiddleware } from "@convex-dev/auth/nextjs/server"; export default convexAuthNextjsMiddleware(); export const config = { matcher: ["/((?!.\..|_next).)", "/", "/(api|trpc)(.)"], };
Sara
Sara12h ago
can you try adding the redirectTo:"/dashboard" to your signIn page? or to the route you want the users to be redirected to, then we solve your middleware issue I'd change the name to _middleware.ts temporarily
signIn("github",{redirectTo: "/{protectedRoute}"})
signIn("github",{redirectTo: "/{protectedRoute}"})
ILYES DRAGOVIC
ILYES DRAGOVICOP12h ago
I don't have a dashboard page , I setup a new convex project then set up the auth at the beginning it won't redirect to the "/" route the middlware is working fine I guess , I tried adding some console.logs there
Sara
Sara12h ago
also comment out the redirect to from the signout, will be fixed with the middleware fix
ILYES DRAGOVIC
ILYES DRAGOVICOP12h ago
Okay I'll try it thank u
Sara
Sara12h ago
use what ever route you want
ILYES DRAGOVIC
ILYES DRAGOVICOP12h ago
and let you know as soon as I tried renaming the middlware.ts to _middleware.ts it stopped working , and I'm getting POST http://localhost:3000/api/auth 404 (Not Found)
Sara
Sara12h ago
since I don't have much time on my hands, the middleware should look something like: https://labs.convex.dev/auth/authz/nextjs#require-authentication-for-certain-routes and it would only work, if you have used the Server wrapper.
Server-side authentication in Next.js - Convex Auth
Authentication library for your Convex backend
Sara
Sara12h ago
yep! wrap your layout in the server wrapper
ILYES DRAGOVIC
ILYES DRAGOVICOP12h ago
it is wrapped thank you for your time I'll follow the middlware aproach you just sent and see
Sara
Sara12h ago
nextjs/server - Convex Auth
Authentication library for your Convex backend
Sara
Sara12h ago
will, I'll check back when I can, good luck!
ILYES DRAGOVIC
ILYES DRAGOVICOP12h ago
I finally fixed the Convex auth issue 😂 Turns out my code and callbacks were all fine , I simlply tried changing the SITE_URL in the convex dashboard environment variables from https://grandiose-meadowlark-398.convex.site to http://localhost:3000 and it's redirecting to the "/" just fine thanks @Sara apprecite it
No description
Sara
Sara12h ago
Yeah always triple check your variables

Did you find this page helpful?