-
Notifications
You must be signed in to change notification settings - Fork 92
feat: implement Next.js skew protection for Netlify #3023
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This implements Next.js skew protection that automatically routes requests to the appropriate deployment based on deployment IDs, preventing version skew issues during deployments. **Features:** - Automatically enabled when VERCEL_SKEW_PROTECTION_ENABLED=1 - Maps NETLIFY_DEPLOY_ID to VERCEL_DEPLOYMENT_ID for Next.js compatibility - Creates edge function to handle deployment ID routing - Supports all three deployment ID carriers (?dpl, X-Deployment-Id header, __vdpl cookie) - Routes static assets and API routes to old deployments when needed - Allows HTML pages to use current deployment for proper skew protection **Implementation:** - Added skew protection edge function template - Integrated edge function creation into plugin lifecycle - Updated onPreBuild to set deployment ID environment variables - Added comprehensive test coverage - Updated documentation in CLAUDE.md 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
minivan
minivan
reviewed
Jul 31, 2025
...ON_ENABLED Updated environment variable name to use NEXT_ prefix instead of VERCEL_ for better Netlify branding consistency while maintaining the same functionality. Changes: - src/index.ts: Updated env var check and warning message - src/build/functions/edge.ts: Updated env var checks in two locations - tests/integration/skew-protection.test.ts: Updated test env setup - CLAUDE.md: Updated documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
cshawaus
commented
Aug 4, 2025
@biilmann, this is awesome primarily because I had only just put it on my to-do list to explore. I'm looking forward to enabling this as soon as it is merged. 💯
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements Next.js skew protection for Netlify, providing automatic deployment version routing to prevent skew issues during deployments.
Key Features:
Implementation Details
Core Components
NETLIFY_DEPLOY_ID
toVERCEL_DEPLOYMENT_ID
?dpl=<id>
X-Deployment-Id
__vdpl=<id>
Files Changed
src/index.ts
- Added skew protection setup in onPreBuildsrc/build/functions/edge.ts
- Integrated edge function creationsrc/build/templates/skew-protection.tmpl.js
- New edge function templatetests/
- Added comprehensive test coverageCLAUDE.md
- Added project documentationTest Plan
Usage
Enable skew protection by setting:
The plugin automatically:
VERCEL_DEPLOYMENT_ID
fromNETLIFY_DEPLOY_ID
Benefits
This implementation follows the Next.js skew protection specification exactly and provides the same developer experience as Vercel's platform.
🤖 Generated with Claude Code