Skip to content

Conversation

@gmegidish
Copy link
Member

@gmegidish gmegidish commented Nov 26, 2025

Summary by CodeRabbit

  • Performance
    • Enhanced cross-origin request handling to improve response times for API interactions.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

Walkthrough

Added the HTTP CORS header Access-Control-Max-Age with a 24-hour value (86400 seconds) to the CORS middleware. This allows browsers to cache preflight responses for an extended duration, reducing repeated OPTIONS requests.

Changes

Cohort / File(s) Summary
CORS Header Configuration
server/server.go
Added Access-Control-Max-Age: 86400 header to corsMiddleware to extend browser preflight response caching duration

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A header so grand, now takes flight,
Cache those preflight checks, day and night!
Eighty-six thousand seconds of grace,
Fewer requests race through cyberspace. ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: cache preflight cors check for a day' directly and specifically describes the main change: adding CORS preflight caching for 86400 seconds (one day).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-cache-preflight-cors

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
server/server.go (1)

82-82: LGTM! Preflight caching correctly implemented.

The Access-Control-Max-Age header with a 24-hour cache duration will reduce preflight OPTIONS requests from browsers, improving performance. The value and placement are appropriate.

Optional: Extract as a constant for maintainability.

If you anticipate needing to adjust this value or reference it elsewhere, consider extracting it as a constant:

const (
    // Server timeouts
    ReadTimeout  = 10 * time.Second
    WriteTimeout = 10 * time.Second
    IdleTimeout  = 120 * time.Second
    
    // CORS preflight cache duration (24 hours)
    CORSMaxAge = 86400
)

Then reference it in the middleware:

-		w.Header().Set("Access-Control-Max-Age", "86400")
+		w.Header().Set("Access-Control-Max-Age", strconv.Itoa(CORSMaxAge))
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 12528fd and 80d8e79.

📒 Files selected for processing (1)
  • server/server.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: lint
  • GitHub Check: Analyze (go)

@gmegidish gmegidish merged commit e2eea7f into main Nov 26, 2025
14 checks passed
@gmegidish gmegidish deleted the fix-cache-preflight-cors branch December 14, 2025 19:31
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.

2 participants