Closed abtestingalpha closed 1 week ago
The changes introduce a new middleware function to the Express application for handling Cross-Origin Resource Sharing (CORS). This middleware sets the necessary headers for incoming requests and responds with a 200 status for OPTIONS
requests. The existing middleware for logging and request routing remains intact, ensuring that the application continues to function as before while incorporating CORS support.
File Path | Change Summary |
---|---|
packages/rest-api/src/app.ts | Added CORS middleware to handle Access-Control-Allow-* headers and respond to OPTIONS requests. Existing middleware remains unchanged. |
sequenceDiagram
participant Client
participant CORS Middleware
participant Logging Middleware
participant Request Handler
Client->>CORS Middleware: Send Request
CORS Middleware-->>Client: Set CORS Headers
alt OPTIONS Request
CORS Middleware-->>Client: Respond with 200
else Other Request
CORS Middleware->>Logging Middleware: Call next()
Logging Middleware->>Request Handler: Process Request
Request Handler-->>Logging Middleware: Send Response
Logging Middleware-->>Client: Return Response
end
🐇 In the meadow where bunnies play,
CORS has come to save the day!
With headers set and options clear,
Our requests can roam far and near.
So hop along, let’s celebrate,
Middleware magic, oh, isn’t it great! 🌼
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 34.22600%. Comparing base (
36efe55
) to head (4a27a0a
). Report is 3 commits behind head on master.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Latest commit: |
4a27a0a
|
Status: | ✅ Deploy successful! |
Preview URL: | https://57179d01.sanguine-fe.pages.dev |
Branch Preview URL: | https://rest-api-cors.sanguine-fe.pages.dev |
Summary by CodeRabbit