Basic Authentication with Caddy
I serve my app with Caddy and I have a set Basic Authentication in my Caddyfile :
The authentication works (with both Basic auth and better-auth). But when I try to create a new user, I get a 404 Unauthorized response with this header in the response :
However, when I remove the
basic_auth
part from my Caddyfile, it works great.
This is my auth.ts
:
My auth-client.ts
:
And this is how I create a new user :
How can I make this work? Do I need to add basic authentication somewhere in my better-auth configuration?Solution:Jump to solution
To get around, I changed replaced my env variable from
BETTER_AUTH_URL=https://example.com
to BETTER_AUTH_URL=http://localhost:3000
And I added trustedOrigins: ['https://example.com']
in my betterAuth config (auth.ts
)
Is this good practice?...2 Replies