flowfi icon indicating copy to clipboard operation
flowfi copied to clipboard

[Backend] Restrict CORS allowed headers and methods configuration in production environment

Open blurbeast opened this issue 2 months ago • 4 comments

Overview

The backend Express app currently enables permissive CORS configuration (cors()) allowing wildcard origins or broad headers.

Problem

  • Production deployments should restrict Access-Control-Allow-Origin to configured frontend domains and explicitly whitelist required headers.

Proposed Changes

  1. Update CORS options in backend/src/app.ts:
    • Whitelist configured FRONTEND_URL origin in production.
    • Restrict headers to Content-Type, Authorization, X-Request-ID.
    • Restrict methods to GET, POST, PUT, DELETE, OPTIONS.

Acceptance Criteria

  • [ ] Permissive CORS retained only in local development (NODE_ENV !== 'production').
  • [ ] Unauthorized origins rejected with CORS error in production mode.
  • [ ] Preflight OPTIONS requests succeed with cached max-age.

blurbeast avatar Sep 27 '26 05:09 blurbeast

@Saber1Y has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

I’ve reviewed this issue and can configure production CORS to allow only the trusted "FRONTEND_URL" origin, explicitly whitelist the required headers and HTTP methods, and retain permissive settings only in development. I’ll also handle preflight requests with a cached "maxAge" and add tests for allowed and rejected origins.

Please assign this issue to me, you won’t be disappointed, thank you.

ℹ️ Repo Maintainers: To accept this application, review their application or assign @Saber1Y to this issue.

Saber1Y avatar Sep 27 '26 14:09 Saber1Y

@Nife-tanny has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

Hi I would like to work on this issue

ℹ️ Repo Maintainers: To accept this application, review their application or assign @Nife-tanny to this issue.

Nife-tanny avatar Sep 27 '26 15:09 Nife-tanny

Congratulations, @Nife-tanny! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.

🧑‍💻 @Nife-tanny: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

🌊 Happy Wave 🌊

drips-wave[bot] avatar Sep 27 '26 15:09 drips-wave[bot]

This issue has been marked as completed by a Drips Wave moderator for @Nife-tanny as part of the Stellar Wave Program's 9th Wave 🥳

Moderator's reason: [Auto-assessed] The PR was merged by maintainers (mergedAt 2026-10-09T07:04:02Z). The changes successfully implement production CORS restrictions for allowed origins, headers, methods, and preflight caching while keeping development environments flexible, backed by comprehensive test suites.

😎 @Nife-tanny: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here.

🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

ℹ️ Note: This issue was marked complete via moderation. Points were issued even though the GitHub issue remains open.

drips-wave[bot] avatar Oct 11 '26 17:10 drips-wave[bot]