diff options
author | 2025-02-12 14:57:03 +0000 | |
---|---|---|
committer | 2025-02-12 14:57:03 +0000 | |
commit | 8d4e566f5420c8a5406e1e40e8bae1c1f87cbe37 (patch) | |
tree | ad8cf069f784b7e739f4ce29ce53c4c368dd167f /packages/integrations/netlify/src | |
parent | 3b669555d7ab9da5427e7b7037699d4f905d3536 (diff) | |
download | astro-8d4e566f5420c8a5406e1e40e8bae1c1f87cbe37.tar.gz astro-8d4e566f5420c8a5406e1e40e8bae1c1f87cbe37.tar.zst astro-8d4e566f5420c8a5406e1e40e8bae1c1f87cbe37.zip |
feat: add support for automatic session driver config (#13145)
* feat: add support for automatic session driver config
* chore: fix error logic
* Lint test
* Add node support
* Add node test fixture
* Lock
* Add Netlify support
* Use workspace Astro version
* Format
* Changeset
* Add tests
* Add dep for tests
* chore: fix repo URL
* temp log
* Fix module resoltuion
* [skip ci] Update changeset
* chore: bump peer dependencies
* Changes from review
* Changeset changes from review
* Apply suggestions from code review
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
* More changeset detail
* Lock
---------
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Diffstat (limited to 'packages/integrations/netlify/src')
-rw-r--r-- | packages/integrations/netlify/src/index.ts | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/packages/integrations/netlify/src/index.ts b/packages/integrations/netlify/src/index.ts index d7c1b14f1..3f016a5e1 100644 --- a/packages/integrations/netlify/src/index.ts +++ b/packages/integrations/netlify/src/index.ts @@ -510,7 +510,7 @@ export default function netlifyIntegration( return { name: '@astrojs/netlify', hooks: { - 'astro:config:setup': async ({ config, updateConfig }) => { + 'astro:config:setup': async ({ config, updateConfig, logger }) => { rootDir = config.root; await cleanFunctions(); @@ -518,6 +518,32 @@ export default function netlifyIntegration( const enableImageCDN = isRunningInNetlify && (integrationConfig?.imageCDN ?? true); + let session = config.session; + + if (config.experimental.session && !session?.driver) { + logger.info( + `Configuring experimental session support using ${isRunningInNetlify ? 'Netlify Blobs' : 'filesystem storage'}`, + ); + session = isRunningInNetlify + ? { + ...session, + driver: 'netlify-blobs', + options: { + name: 'astro-sessions', + consistency: 'strong', + ...session?.options, + }, + } + : { + ...session, + driver: 'fs-lite', + options: { + base: fileURLToPath(new URL('sessions', config.cacheDir)), + ...session?.options, + }, + }; + } + updateConfig({ outDir, build: { @@ -525,6 +551,7 @@ export default function netlifyIntegration( client: outDir, server: ssrBuildDir(), }, + session, vite: { server: { watch: { |