From 826c88f63fca276a927eb14c5c45d3ab9959ca96 Mon Sep 17 00:00:00 2001 From: Chris Kanich Date: Mon, 30 Dec 2024 10:35:07 -0600 Subject: [PATCH] added changeset --- .changeset/hot-baboons-own.md | 5 ++++ examples/basics/astro.config.mjs | 10 +++++++- examples/basics/src/pages/index.astro | 7 ++++-- examples/ssr/astro.config.mjs | 1 + examples/ssr/src/pages/index.astro | 35 +++++---------------------- 5 files changed, 26 insertions(+), 32 deletions(-) create mode 100644 .changeset/hot-baboons-own.md diff --git a/.changeset/hot-baboons-own.md b/.changeset/hot-baboons-own.md new file mode 100644 index 0000000000000..6ce090c2e51a8 --- /dev/null +++ b/.changeset/hot-baboons-own.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +ensure session regeneration diff --git a/examples/basics/astro.config.mjs b/examples/basics/astro.config.mjs index e762ba5cf616b..57bf494bc314d 100644 --- a/examples/basics/astro.config.mjs +++ b/examples/basics/astro.config.mjs @@ -1,5 +1,13 @@ // @ts-check import { defineConfig } from 'astro/config'; +import node from '@astrojs/node'; + // https://astro.build/config -export default defineConfig({}); +export default defineConfig({ + experimental: { session: { driver: 'fs' } }, + + adapter: node({ + mode: 'standalone', + }), +}); diff --git a/examples/basics/src/pages/index.astro b/examples/basics/src/pages/index.astro index c04f3602b5521..4f72f21eb7152 100644 --- a/examples/basics/src/pages/index.astro +++ b/examples/basics/src/pages/index.astro @@ -1,11 +1,14 @@ --- import Welcome from '../components/Welcome.astro'; import Layout from '../layouts/Layout.astro'; - +export const prerender = false; // Welcome to Astro! Wondering what to do next? Check out the Astro documentation at https://docs.astro.build // Don't want to use any of this? Delete everything in this file, the `assets`, `components`, and `layouts` directories, and start fresh. + +await Astro.session.regenerate(); +const sessionId = `the current session ID is: ${Astro.cookies.get('astro-session')?.value}`; --- - + This page refreshes its session ID on every load. It is currently {sessionId} diff --git a/examples/ssr/astro.config.mjs b/examples/ssr/astro.config.mjs index 78d88cb1aa06b..073725458a502 100644 --- a/examples/ssr/astro.config.mjs +++ b/examples/ssr/astro.config.mjs @@ -5,6 +5,7 @@ import node from '@astrojs/node'; // https://astro.build/config export default defineConfig({ + experimental: { session: { driver: 'fs' } }, output: 'server', adapter: node({ mode: 'standalone', diff --git a/examples/ssr/src/pages/index.astro b/examples/ssr/src/pages/index.astro index 1ce70bc81ea6f..3572a1c003f36 100644 --- a/examples/ssr/src/pages/index.astro +++ b/examples/ssr/src/pages/index.astro @@ -1,33 +1,10 @@ --- -import Header from '../components/Header.astro'; -import Container from '../components/Container.astro'; -import ProductListing from '../components/ProductListing.astro'; -import { getProducts } from '../api'; -import '../styles/common.css'; +export const prerender = false; +// Welcome to Astro! Wondering what to do next? Check out the Astro documentation at https://docs.astro.build +// Don't want to use any of this? Delete everything in this file, the `assets`, `components`, and `layouts` directories, and start fresh. -const products = await getProducts(Astro.request); +await Astro.session.regenerate(); +const sessionId = `the current session ID is: ${Astro.cookies.get('astro-session')?.value}`; --- - - - Online Store - - - -
- - - -

Product Listing

-
-
- - +This page refreshes its session ID on every load. It is currently {sessionId}