Conversation
…isable that and do not generate the ETag header on the OPTIONS response.
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (7)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR introduces CORS (Cross-Origin Resource Sharing) middleware to the Harmony service. It adds handlers for preflight OPTIONS requests and general CORS headers, registers them in the router, and updates authorization middleware to bypass OPTIONS requests to prevent blocking preflight requests. Changes
Sequence DiagramsequenceDiagram
participant Client
participant Router
participant CORSHandler
participant AuthHandler
participant NextMiddleware
Client->>Router: OPTIONS /api/resource (preflight)
Router->>CORSHandler: optionsHandler
CORSHandler->>CORSHandler: Set CORS headers
CORSHandler->>Client: 204 No Content (end)
Client->>Router: POST /api/resource
Router->>CORSHandler: corsHandler
CORSHandler->>CORSHandler: Set Access-Control-Allow-Origin
CORSHandler->>AuthHandler: next()
AuthHandler->>AuthHandler: Check auth (skip if OPTIONS)
AuthHandler->>NextMiddleware: next()
NextMiddleware->>Client: Response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Jira Issue ID
HARMONY-2317
Description
EDSC is looking to call the harmony capabilities endpoint from JavaScript code in the browser. They were hitting issues with cross-origin issues in their testing because harmony did not support CORS.
Local Test Steps
Verify you can reach the OPTIONS routes now and the CORS information is included in the headers:
curl -v -X OPTIONS http://localhost:3000/capabilitiesVerify that all routes include the Access-Control-Allow-Origin now
curl -v -X OPTIONS http://localhost:3000/capabilitiesI deployed this change to the harmony SIT environment and EDSC verified it is working correctly for them now.
PR Acceptance Checklist
Summary by CodeRabbit
New Features
Tests