Hosting
Environment variables
Set the following environment variables in your hosting environment:
.env
# Required in production — used to sign and verify sessions
BETTER_AUTH_SECRET=your-secret-here
# The public URL your Better Auth instance is reachable at
BETTER_AUTH_URL=https://your-app.example.com
Pass them to your Better Auth config:
config/better-auth.ts
import { betterAuth } from "better-auth";
import { strapiAdapter } from "@strapi-community/plugin-better-auth";
const auth = () =>
betterAuth({
database: strapiAdapter(),
secret: process.env.BETTER_AUTH_SECRET,
baseURL: process.env.BETTER_AUTH_URL,
trustedOrigins: ['http://localhost:3000'],
advanced: {
database: {
generateId: "serial",
},
},
});
export default auth;