* feat: add adapter support for internal fetch headers (Netlify skew protection)
Adds a new generic mechanism for adapters to inject headers into Astro's internal fetch calls. This enables features like Netlify's skew protection.
Changes:
- Add `runtimeConfig.internalFetchHeaders` to AstroAdapter interface
- Create `astro:adapter-config/client` virtual module
- Update Actions, View Transitions, Server Islands, and Prefetch to use adapter headers
- Implement Netlify skew protection with DEPLOY_ID header
- Generate `.netlify/v1/skew-protection.json` configuration file
- Add comprehensive test fixture for skew protection
* fix: resolve TypeScript errors in adapter config implementation
- Add type declarations for astro:adapter-config/client virtual module
- Add manifest property to SSRResult interface
- Fix Object.entries type assertions in prefetch and router
- Add explicit return type to Netlify adapter's internalFetchHeaders function
* refactor: extract internalFetchHeaders from manifest into SSRResult
Follow existing pattern of extracting specific fields from manifest rather than passing the entire manifest object to SSRResult. This matches how other fields like base, trailingSlash, and serverIslandNameMap are handled.
* Address PR feedback: clean up tests and update comment
- Remove incomplete test stubs for actions and view transitions
- Remove unused manifestPath variable
- Update prefetch comment to be less strict about dependencies
* Fix import sorting in create-vite and router files
* Fix skew protection test to check correct manifest file
The test was checking ssr.mjs which is just a wrapper, but the actual
serialized manifest is in the manifest_*.mjs file in the build directory.
* Fix virtual module to return empty headers during SSR
This prevents timeouts in integration tests where client-side files
importing the virtual module are processed during SSR.
* review changes
* Update .changeset/netlify-skew-protection.md
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
* fix lint
* Update packages/astro/dev-only.d.ts
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
* Add assetQueryParams support for skew protection
This adds a new `assetQueryParams` configuration option to the adapter client config that allows adapters to append query parameters to all static asset URLs. This is used for Vercel's skew protection to track deployment versions.
Changes:
- Extended AstroAdapter.client interface with assetQueryParams property
- Modified getAssetsPrefix() to accept and append query parameters
- Updated manifest builder to include query params in all asset URLs
- Updated SSR element creation functions to support query params
- Updated Vercel adapter to provide deployment ID as query param when skew protection is enabled
This ensures that all asset requests include the deployment identifier, allowing Vercel to route them to the correct deployment version if there's a version mismatch between client and server.
* update imports
* update based on review comments
* switch to use URLSearchParams
* remove unneeded file
* align vercel impl with how the other works
* focus changesets a bit more
* Update .changeset/astro-asset-query-params.md
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
* Update .changeset/astro-asset-query-params.md
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
* explain how to do it yourself too
* oops
* Update packages/integrations/vercel/src/index.ts
Co-authored-by: Steven <steven@ceriously.com>
---------
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
Co-authored-by: Steven <steven@ceriously.com>
* [ci] release
* Skip yarn test that fails with unpublished dependencies
The yarn test packs astro and attempts to install it, which fails when
workspace dependencies like @astrojs/internal-helpers have been bumped
but not yet published to npm. Skip this test to allow the release to proceed.
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matthew Phillips <matthew@skypack.dev>
* feat: load Netlify Vite plugin
* chore: update `@netlify/vite-plugin`
* update plugin and add tests
* Update pnpm-lock.yaml
* remove unused code
* Deps
* update plugin
* remove unused file
* Apply suggestions from code review
Co-authored-by: Matt Kane <m@mk.gg>
* Upgrade vite plugin
* satisfy linter
* Upgrade vite plugin
* refactor: use Netlify primitives
* make imageCDN an opt out, not an opt in
* remove outside netlify test, for now we are never outside
* update pnpm-lock
* invalidate the astro session when restarting dev server
* Update to latest vite plugin, functions and blobs
* Add changeset for @astrojs/netlify on @netlify/vite-plugin
* apply Sarah's changeset improvements
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
---------
Co-authored-by: Matt Kane <m@mk.gg>
Co-authored-by: chee <chee.rabbits@netlify.com>
Co-authored-by: chee <chee@rabbits.computer>
Co-authored-by: chee <yay@chee.party>
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>