Add HTTPS redirect middleware for production #394

Open
pook wants to merge 50 commits from feat/https-redirect-middleware into main
Owner

Summary

  • Adds Hono middleware that redirects HTTP→HTTPS (301) when NODE_ENV=production
  • Checks x-forwarded-proto header first (for reverse proxies like Railway/Render), falls back to URL protocol detection
  • Skips /health, /api/health, and /billing/webhook to avoid breaking monitoring probes and Stripe webhook delivery
  • Placed early in middleware chain (after body limit, before logger/auth/rate-limit)

Test plan

  • 10 unit tests covering: redirect behavior, header detection, skip paths, query string preservation, non-production passthrough
  • Existing middleware tests still pass (24/24)

Ref: contractpilot #353

🤖 Generated with Claude Code

## Summary - Adds Hono middleware that redirects HTTP→HTTPS (301) when `NODE_ENV=production` - Checks `x-forwarded-proto` header first (for reverse proxies like Railway/Render), falls back to URL protocol detection - Skips `/health`, `/api/health`, and `/billing/webhook` to avoid breaking monitoring probes and Stripe webhook delivery - Placed early in middleware chain (after body limit, before logger/auth/rate-limit) ## Test plan - [x] 10 unit tests covering: redirect behavior, header detection, skip paths, query string preservation, non-production passthrough - [x] Existing middleware tests still pass (24/24) Ref: contractpilot #353 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Add HTTPS redirect middleware for production environments
Some checks are pending
CI Quality Gate / Lint / Typecheck / Test / Build (pull_request) Waiting to run
c20cbe08d5
Redirects HTTP→HTTPS via 301 using x-forwarded-proto header (for reverse
proxy setups like Railway/Render) with req.secure fallback. Skips health
check and webhook routes to avoid breaking monitoring and Stripe delivery.
Placed early in middleware chain, before auth and rate limiting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
feat: issue #389 add-express-middleware-that-redirects-al (agent task liancebot389)
Some checks failed
CI Quality Gate / Lint / Typecheck / Test / Build (pull_request) Has been cancelled
91c7217584
Some checks failed
CI Quality Gate / Lint / Typecheck / Test / Build (pull_request) Has been cancelled
This pull request has changes conflicting with the target branch.
  • .forgejo/workflows/ci.yml
  • bun.lock
  • package.json
  • packages/api/src/db/schema.ts
  • packages/api/src/index.ts
  • packages/api/src/middleware/rate-limit.ts
  • packages/api/src/middleware/security-headers.ts
  • packages/api/src/routes/generate-tos.ts
  • packages/api/src/routes/generate.ts
  • packages/api/src/routes/health.ts
  • packages/api/src/routes/questionnaire.ts
  • packages/api/src/services/document-generator.ts
  • packages/api/src/services/llm.ts
  • packages/api/src/templates/index.ts
  • packages/api/tsconfig.json
  • packages/shared/src/types.ts
  • packages/web/src/app/questionnaire/page.tsx
  • packages/web/src/components/documents/DocumentList.tsx
  • packages/web/src/components/questionnaire/ReviewStep.tsx
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/https-redirect-middleware:feat/https-redirect-middleware
git switch feat/https-redirect-middleware
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot!394
No description provided.