celestia-node icon indicating copy to clipboard operation
celestia-node copied to clipboard

feat(api): allow configurable CORS policy

Open TheRealSibasishBehera opened this issue 6 months ago • 3 comments

Fixes #3481 kind:feat

Enforces CORS configuration rules and adds middleware handling.

  • Introduces CORS flags (--rpc.cors-enabled, --rpc.cors-allowed-origins, --rpc.cors-allowed-methods, --rpc.cors-allowed-headers)

  • Requires --rpc.cors-enabled=true to use any CORS-related flags

  • Using --rpc.skip-auth allows all CORS settings (equivalent to * wildcard)

  • Provides default values when partial configuration is given

  • Fully overwrites (does not extend) settings when all configurations are provided, giving users complete control

TheRealSibasishBehera avatar May 13 '25 11:05 TheRealSibasishBehera

@walldiss Could you please review this PR? Let me know if anything needs further changes. Many thanks 🙏

TheRealSibasishBehera avatar May 18 '25 18:05 TheRealSibasishBehera

@walldiss Thanks for looking into the middleware libraries. I’ve added tests for the middleware function—let me know if you think it needs any improvement or additional tests.

TheRealSibasishBehera avatar May 26 '25 11:05 TheRealSibasishBehera

Codecov Report

Attention: Patch coverage is 79.54545% with 27 lines in your changes missing coverage. Please review.

Project coverage is 35.54%. Comparing base (2469e7a) to head (2585c13). Report is 516 commits behind head on main.

Files with missing lines Patch % Lines
nodebuilder/rpc/flags.go 77.77% 6 Missing and 12 partials :warning:
nodebuilder/rpc/constructors.go 0.00% 6 Missing :warning:
cmd/util.go 0.00% 3 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4266      +/-   ##
==========================================
- Coverage   44.83%   35.54%   -9.29%     
==========================================
  Files         265      323      +58     
  Lines       14620    25195   +10575     
==========================================
+ Hits         6555     8956    +2401     
- Misses       7313    15270    +7957     
- Partials      752      969     +217     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov-commenter avatar Jun 04 '25 16:06 codecov-commenter