acacode / swagger-typescript-api

Generate the API Client for Fetch or Axios from an OpenAPI Specification
MIT License
3.27k stars 354 forks source link

Avoid CORS preflight for GET requests when unneeded #891

Closed h closed 1 month ago

h commented 1 month ago

By default, swagger-typescript-api forces the browser to send a CORS pre-flight request even for GET requests. This is because the Content-Type is set even for GET requests, which would otherwise be considered a "simple" request, thereby avoiding the CORS pre-flight.

Since GET requests do not contain a request body, the Content-Type is always ignored. It should be ignored for GET requests so that the CORS preflight can be avoided.

h commented 1 month ago

I stand corrected: the latest version of swagger-typescript-api already addresses this.

Closing issue.