Skip to content

fix(maintenance): extract bypass cookie config into shared module - #885

Open
Rafiat30 wants to merge 2 commits into
Iris-IV:mainfrom
Rafiat30:fix/maintenance-bypass-cookie-config
Open

fix(maintenance): extract bypass cookie config into shared module#885
Rafiat30 wants to merge 2 commits into
Iris-IV:mainfrom
Rafiat30:fix/maintenance-bypass-cookie-config

Conversation

@Rafiat30

Copy link
Copy Markdown

Closes #556

Summary

BYPASS_COOKIE_MAX_AGE was defined and exported from middleware.ts and was already being applied as max-age when MaintenanceBypass.tsx sets the maintenance bypass cookie via document.cookie. The remaining issue was architectural: a client component was importing constants from an Edge-runtime middleware file.

Changes

  • New file: src/lib/maintenanceConfig.ts — shared MAINTENANCE_COOKIE and BYPASS_COOKIE_MAX_AGE constants.
  • Modified: src/middleware.ts — imports the constants from the new shared module instead of defining/exporting them locally.
  • Modified: src/components/MaintenanceBypass.tsx — imports the constants from @/lib/maintenanceConfig instead of @/middleware.

Why

Client components importing from middleware.ts risk 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 correct max-age.

How to test

  1. Set NEXT_PUBLIC_MAINTENANCE_MODE=true and NEXT_PUBLIC_MAINTENANCE_ALLOWLIST=<your wallet address> in .env.local.
  2. Run the app, connect the allowlisted wallet.
  3. Inspect document.cookie in devtools — maintenance_bypass should have max-age=86400.
  4. npm run typecheck and npm test pass.

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
@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@sshdopey

Copy link
Copy Markdown
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
@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] middleware.ts BYPASS_COOKIE_MAX_AGE exported but never used to set cookie — bypass tokens expire with browser session

2 participants