fix(maintenance): extract bypass cookie config into shared module - #885
Open
Rafiat30 wants to merge 2 commits into
Open
fix(maintenance): extract bypass cookie config into shared module#885Rafiat30 wants to merge 2 commits into
Rafiat30 wants to merge 2 commits into
Conversation
Move MAINTENANCE_COOKIE and BYPASS_COOKIE_MAX_AGE out of middleware.ts into src/lib/maintenanceConfig.ts so the client-side MaintenanceBypass component no longer imports from an Edge-runtime middleware file. Behavior is unchanged: the bypass cookie already applied max-age from BYPASS_COOKIE_MAX_AGE, this just fixes the import graph. Refs Iris-IV#556
|
@Rafiat30 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Auto-review failed (API error). Leaving PR for human review. |
Adds regression coverage for the maintenanceConfig.ts extraction: locks the 24h BYPASS_COOKIE_MAX_AGE and MAINTENANCE_COOKIE values, verifies the exact cookie string MaintenanceBypass.tsx builds embeds max-age from the shared constant, and covers the no-wallet-connected render path. Refs Iris-IV#556
Contributor
|
Auto-review failed (API error). Leaving PR for human review. |
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
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.
Closes #556
Summary
BYPASS_COOKIE_MAX_AGEwas defined and exported frommiddleware.tsand was already being applied asmax-agewhenMaintenanceBypass.tsxsets the maintenance bypass cookie viadocument.cookie. The remaining issue was architectural: a client component was importing constants from an Edge-runtime middleware file.Changes
src/lib/maintenanceConfig.ts— sharedMAINTENANCE_COOKIEandBYPASS_COOKIE_MAX_AGEconstants.src/middleware.ts— imports the constants from the new shared module instead of defining/exporting them locally.src/components/MaintenanceBypass.tsx— imports the constants from@/lib/maintenanceConfiginstead of@/middleware.Why
Client components importing from
middleware.tsrisk pulling Edge/Next.js-server-only code into the client bundle. Moving the shared constants into a plain module used by both sides removes that coupling without changing runtime behavior — the cookie already carried the correctmax-age.How to test
NEXT_PUBLIC_MAINTENANCE_MODE=trueandNEXT_PUBLIC_MAINTENANCE_ALLOWLIST=<your wallet address>in.env.local.document.cookiein devtools —maintenance_bypassshould havemax-age=86400.npm run typecheckandnpm testpass.