Skip to content

Feat/be cors csp#493

Open
NnamdiCyber wants to merge 7 commits into
Pulsefy:mainfrom
NnamdiCyber:feat/be-cors-csp
Open

Feat/be cors csp#493
NnamdiCyber wants to merge 7 commits into
Pulsefy:mainfrom
NnamdiCyber:feat/be-cors-csp

Conversation

@NnamdiCyber
Copy link
Copy Markdown

Closes #420

Summary

Replaces the hardcoded CORS block in main.ts with a tested, environment-driven config (#420 BE-34).

Changes

  • cors.config.tsbuildCorsOptions(): static allowlist, Vercel preview URL pattern, no wildcard in production
  • env.schema.ts + app-config.service.tsCORS_ALLOWED_ORIGINS, CORS_VERCEL_PROJECT env vars
  • main.ts — replaced inline CORS block with buildCorsOptions()
  • cors.config.unit.spec.ts — 14 passing tests covering all CORS flows

Acceptance Criteria

  • ✅ Frontend can call backend from Vercel preview and production without manual toggles
  • ✅ Disallowed origins fail with consistent errors
  • ✅ No wildcard CORS in production

Config required in production

CORS_ALLOWED_ORIGINS=https://quickex.to,https://app.quickex.to
CORS_VERCEL_PROJECT=quickex-frontend

- Add backend-ci.yml: lint, type-check, unit + integration tests
- Add backend-release.yml: build Docker image, run migrations, deploy
  staging, deploy production (with manual approval gate), rollback job
- Add composite actions: run-migrations and deploy-app
- Add multi-stage Dockerfile and .dockerignore for backend
- Deprecate old backend.yml stub

Closes Pulsefy#416
- Extract CORS logic into cors.config.ts with buildCorsOptions()
- Support static origin allowlist via CORS_ALLOWED_ORIGINS env var
- Support Vercel preview URLs via CORS_VERCEL_PROJECT slug pattern
- No wildcard in production; open in dev/test
- Add CORS_ALLOWED_ORIGINS + CORS_VERCEL_PROJECT to env schema and AppConfigService
- Replace hardcoded origin list in main.ts with buildCorsOptions()
- 14 unit tests covering all CORS flows (allowed, blocked, preview, spoofing)

Closes Pulsefy#420
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 28, 2026

@NnamdiCyber 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

@Cedarich
Copy link
Copy Markdown
Contributor

Fix workflow

@Cedarich
Copy link
Copy Markdown
Contributor

Fix workflow

@Cedarich
Copy link
Copy Markdown
Contributor

@NnamdiCyber

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.

BE-34: Production-Grade CORS + CSP Support for Wallet Integrations

2 participants