mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-07 20:37:44 +00:00
fix: app name shouldn't be used to prefix cookies (#447)
This commit is contained in:
@@ -23,6 +23,7 @@ const libsql = new LibsqlDialect({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const auth = betterAuth({
|
export const auth = betterAuth({
|
||||||
|
appName: "Better Auth Demo",
|
||||||
database: {
|
database: {
|
||||||
dialect: libsql,
|
dialect: libsql,
|
||||||
type: "sqlite",
|
type: "sqlite",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Cookies are used to store data such as session tokens, OAuth state, and more. Al
|
|||||||
|
|
||||||
### Cookie Prefix
|
### Cookie Prefix
|
||||||
|
|
||||||
Better Auth cookies will follow `${prefix}.${cookie_name}` format by default. The prefix equals to the `appName` provided in the auth options by default. If not provided, the prefix will be "better-auth". You can change the prefix by setting `cookiePrefix` in the `advanced` object of the auth options.
|
Better Auth cookies will follow `${prefix}.${cookie_name}` format by default. The prefix will be "better-auth" by default. You can change the prefix by setting `cookiePrefix` in the `advanced` object of the auth options.
|
||||||
|
|
||||||
```ts title="auth.ts"
|
```ts title="auth.ts"
|
||||||
import { betterAuth } from "better-auth"
|
import { betterAuth } from "better-auth"
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ export function createCookieGetter(options: BetterAuthOptions) {
|
|||||||
cookieName: string,
|
cookieName: string,
|
||||||
overrideAttributes: Partial<CookieOptions> = {},
|
overrideAttributes: Partial<CookieOptions> = {},
|
||||||
) {
|
) {
|
||||||
const prefix =
|
const prefix = options.advanced?.cookiePrefix || "better-auth";
|
||||||
options.advanced?.cookiePrefix || options.appName || "better-auth";
|
|
||||||
const name =
|
const name =
|
||||||
options.advanced?.cookies?.[cookieName as "session_token"]?.name ||
|
options.advanced?.cookies?.[cookieName as "session_token"]?.name ||
|
||||||
`${prefix}.${cookieName}`;
|
`${prefix}.${cookieName}`;
|
||||||
|
|||||||
Reference in New Issue
Block a user