Skip to content

Conversation

@matthewp
Copy link
Contributor

@matthewp matthewp commented Oct 14, 2025

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
  • Closes @astrojs/vercel skew protection doesn't work #14545

Testing

Docs

…otection)

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
@changeset-bot
Copy link

changeset-bot bot commented Oct 14, 2025

🦋 Changeset detected

Latest commit: a0424b6

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: integration Related to any renderer integration (scope) pkg: astro Related to the core `astro` package (scope) docs pr semver: minor Change triggers a `minor` release labels Oct 14, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

- 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
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.
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 14, 2025

CodSpeed Performance Report

Merging #14543 will not alter performance

Comparing netlify-skew-protection (a0424b6) with main (63b2568)

Summary

✅ 6 untouched

- Remove incomplete test stubs for actions and view transitions
- Remove unused manifestPath variable
- Update prefetch comment to be less strict about dependencies
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.
This prevents timeouts in integration tests where client-side files
importing the virtual module are processed during SSR.
@matthewp matthewp added this to the v5.15.0 milestone Oct 14, 2025
@matthewp matthewp marked this pull request as ready for review October 14, 2025 20:56
@matthewp matthewp marked this pull request as draft October 14, 2025 20:56
@matthewp matthewp added the pr preview Apply this label to a PR to generate a preview release label Oct 14, 2025
@github-actions github-actions bot removed the pr preview Apply this label to a PR to generate a preview release label Oct 14, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 14, 2025

npm i https://pkg.pr.new/astro@14543
npm i https://pkg.pr.new/@astrojs/netlify@14543

commit: 4e36b0d

@matthewp matthewp marked this pull request as ready for review October 14, 2025 21:44
@florian-lefebvre
Copy link
Member

Is the virtual module meant to be exposed to users or is it purely internal?

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feature has a mixture of "client" and "runtime" concepts that seem to overlap, however we know that they are two different things.

I think we should normalise the nomenclature in our code and docs

@matthewp matthewp self-assigned this Oct 15, 2025
@matthewp
Copy link
Contributor Author

matthewp commented Oct 15, 2025

@florian-lefebvre

Is the virtual module meant to be exposed to users or is it purely internal?

It's more or less internal. I thought about making it exposed to the user so they could use it in their own fetch calls but using the DEPLOY_ID in your own fetch calls is already easy enough.

Comment on lines 5 to 10
Adds support for `assetQueryParams` and `internalFetchHeaders` in the Netlify adapter. When deployed to Netlify, the adapter now:

- Includes the deployment ID in asset URLs via `assetQueryParams` (query parameter: `dpl`)
- Includes the deployment ID in internal fetch requests via `internalFetchHeaders` (header: `X-Netlify-Deploy-ID`)

This enables Netlify's skew protection feature, which ensures that client and server versions match during deployments by tracking the deployment ID across both asset requests and internal API calls.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly implementation detail. I'd lead on the fact this adds support for skew protection, and then say that it adds the query params and fetch headers. Users don't care about which adapter API it uses.

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so this changed since I approved! 😄

Some suggestions, that I think somewhat addresses @ascorbic 's feedback!

Copy link
Contributor

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Netlify team said that the feature could do with having a config option, but make it on by default. The Vercel one is off by default. I wonder if we should align them: both on by default but with an opt-out.

@matthewp
Copy link
Contributor Author

@ascorbic Their suggestion was out of caution. I'd rather not add flag without knowing a use-case for it. If people complain for some reason we can add a flag later.

I've moved the Vercel implementation to use the VERCEL_SKEW_PROTECTION_ENABLED env as suggested, so it will be on by default. Can remove its option later assuming people aren't using it.

@ascorbic
Copy link
Contributor

@matthewp I think that as it is a brand new feature on Netlify and users will probably not even know they're using it, it would be good to at least have a way to opt-out in case it breaks stuff.

@matthewp
Copy link
Contributor Author

@ascorbic If it breaks stuff they can downgrade the package until we fix it. If we add a flag and it breaks stuff they still need to find out and then set the flag to false. Not any easier than just downgrading. If we have a flag we have to keep it until a major at least, whereas if there's no flag we can either just fix the bug or if we find there's a real use-case for disabling it we can then add said flag.

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just making it extra clear that docs is again approving the newest version of the changesets!

Docs PR content is also approved, and will be good to go! (Just fiddling with larger changes the newer content is causing in other pages like changed anchor links)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs pr pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) semver: minor Change triggers a `minor` release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@astrojs/vercel skew protection doesn't work

7 participants