Better auth routes end up with 404 while trying to test it via ngrok #15831
Replies: 1 comment 6 replies
|
The 404 on Better Auth routes (like email verification links) through ngrok is almost always a Better Auth validates the origin of incoming requests. When you use ngrok, the domain changes from Fix: update your Better Auth config to include the ngrok URL: // src/lib/auth.ts (or wherever your auth config is)
export const auth = betterAuth({
baseURL: process.env.BETTER_AUTH_URL, // set this to your ngrok URL
trustedOrigins: [
"http://localhost:5173",
"https://your-ngrok-subdomain.ngrok-free.app" // add ngrok URL
],
// ...
});Also make sure For the email verification specifically, the flow is:
Check your If you're using ngrok's free tier, note that the URL changes each session. You'd need to update the config each time, or use a fixed subdomain with a paid plan. |
Uh oh!
There was an error while loading. Please reload this page.
As the title says, I update the
baseUrlto the temp ngrok url while testing. The cookies work fine, I can use the app with a registered user. But none of the BA routes work. I have the email verification enabled and I can't verify emails, because the verify link lands on 404. The url itself is correct, it has the correct domain, but it just throws 404.All reactions