#Change name Session Cookie with cloudflare adapter

1 messages · Page 1 of 1 (latest)

paper ivy
#

Hello,

I want to change the name of the Session cookie with

adapter: cloudflare({
    imageService: "passthrough",
    platformProxy: { enabled: true },
    sessionKVBindingName: 'test_session',
}),
session: {
    cookie: {
        name: "test-session-cookie",
        sameSite: "lax",
        secure: true,
    }
},

see also: https://docs.astro.build/en/reference/configuration-reference/#sessioncookie

but then i get an error: session.driver: Required

so i tried:

adapter: cloudflare({
    imageService: "passthrough",
    platformProxy: { enabled: true },
    sessionKVBindingName: 'test_session',
}),
session: {
    driver: "cloudflareKVBinding",
    options: {
        binding: 'test_session',
    },
    cookie: {
        name: "test-session-cookie",
        sameSite: "lax",
        secure: true,
    }
},

then i get an error: [unstorage] [cloudflare] Invalid binding test_session: undefined

I don't know how to make this configuration works. Hopefully can somebody help me with this.

formal orbit
#

What’s your wrangler file
Look like?

paper ivy
# formal orbit What’s your wrangler file Look like?

{
"name": "test-astro",
"compatibility_date": "2025-03-26",
"pages_build_output_dir": "./dist",
"d1_databases": [
{
"binding": "DB",
"database_name": "test",
"database_id": "xxxx-xxxx-xxxx-xxxx",
"migrations_dir": "drizzle/migrations",
"migrations_table": "__drizzle_migrations"
}
],
"kv_namespaces": [
{
"binding": "activationtoken",
"id": "xxxxxxxxxxx"
},
{
"binding": "test_session",
"id": "xxxxxxxxxxxxxxxxx"
}
],
"vars": {
"TURNSTILE_SITE_KEY": "0xxxxxxxxxx"
}
}

paper ivy
#

The problem is only on local development when i run bun dev.

my package.json contains

"scripts": {
    "dev": "wrangler types && astro dev",
    "build": "wrangler types && bun run astro build",
    "preview": "wrangler types && wrangler pages dev ./dist",

@jagged sail do you know how i can change the session name and set the correct binding.

jagged sail
#

Locally it doesn’t use the KV for sessions yet. I am planning to refactor that soon.

#

It falls back to fs. @peak ferry Did you hard code the binding name for the filesystem fallback?

#

@paper ivy We are talking about local development right?

paper ivy
#

Yes it is for local development

peak ferry
#

It only falls back to fs if it's being automatically set by the adapter. If you've manually set the driver it won't override it.

#

The session.driver: Required bit sounds like a bug. Can you open an issue with a minimal reproduction?

near pikeBOT
#

Ouch. Guess it's time to squash some bugs.

Please open an issue on the withastro/astro repo.