acacode / swagger-typescript-api

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

Avoid CORS preflight for GET requests when unneeded #891

Closed h closed 3 months ago

h commented 3 months 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 3 months ago

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

Closing issue.