Skip to content

Fix CORS handling across API - #1

Merged
IAmJSD merged 1 commit into
Infrawrench:mainfrom
Daniele-Cangi:agent/fix-cors-handling
Aug 9, 2026
Merged

Fix CORS handling across API#1
IAmJSD merged 1 commit into
Infrawrench:mainfrom
Daniele-Cangi:agent/fix-cors-handling

Conversation

@Daniele-Cangi

@Daniele-Cangi Daniele-Cangi commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes CORS handling across the API so browser clients can correctly use authenticated endpoints.

Changes

  • Handle OPTIONS requests before endpoint routing.
  • Advertise PUT and DELETE in Access-Control-Allow-Methods.
  • Add Access-Control-Allow-Origin consistently to API responses, including errors and 204 responses.

This keeps the existing authentication and API behavior unchanged while making CORS handling consistent across /authorize, /users, and asset endpoints.

@IAmJSD

IAmJSD commented Aug 9, 2026

Copy link
Copy Markdown
Member

@greptile-apps

@greptile-apps

greptile-apps Bot commented Aug 9, 2026

Copy link
Copy Markdown

Greptile Summary

Adds consistent CORS handling throughout the API.

  • Handles all OPTIONS requests before endpoint routing.
  • Advertises the API’s GET, POST, PUT, and DELETE methods in preflight responses.
  • Adds Access-Control-Allow-Origin to successful, error, and empty responses.

Confidence Score: 5/5

The PR appears safe to merge, with consistent CORS coverage across all reachable response paths.

The new wrapper receives mutable locally constructed responses, all response branches include the origin header, and the global preflight method list is valid even though individual resources implement different subsets.

Important Files Changed

Filename Overview
src/index.ts Centralizes simple-response CORS decoration, expands preflight methods, and moves preflight handling ahead of route dispatch without introducing an identified defect.

Reviews (1): Last reviewed commit: "Fix CORS handling across API" | Re-trigger Greptile

@IAmJSD

IAmJSD commented Aug 9, 2026

Copy link
Copy Markdown
Member

hmmm interesting, I was concerned about the ordering considering there are new methods and I didn't know if it would cause ww3 if some of the methods on some routes being advertised wrong would be a problem but ig not, merging!

@IAmJSD
IAmJSD merged commit ed5a60c into Infrawrench:main Aug 9, 2026
1 check passed
@Daniele-Cangi

Copy link
Copy Markdown
Contributor Author

Yeah that was the one part I double-checked too 😄

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