Skip to content

Commit

Permalink
enhance(cors): call CORS headers factory once (#2238)
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Dec 20, 2022
1 parent b361b8c commit c152105
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-spiders-pay.md
@@ -0,0 +1,5 @@
---
'graphql-yoga': patch
---

Do not call CORS headers factory twice
6 changes: 0 additions & 6 deletions packages/graphql-yoga/src/plugins/useCORS.ts
Expand Up @@ -144,14 +144,8 @@ export function useCORS<TServerContext extends Record<string, any>>(
return {
async onRequest({ request, serverContext, fetchAPI, endResponse }) {
if (request.method.toUpperCase() === 'OPTIONS') {
const headers = await getCORSResponseHeaders<any>(
request,
corsOptionsFactory,
serverContext,
)
const response = new fetchAPI.Response(null, {
status: 204,
headers,
})
endResponse(response)
}
Expand Down

0 comments on commit c152105

Please sign in to comment.