Skip to content

Commit

Permalink
Merge pull request #230 from graphql/fix-optins
Browse files Browse the repository at this point in the history
Handle options requests
  • Loading branch information
JoviDeCroock authored Jan 6, 2025
2 parents b340cf9 + 416b3d6 commit 4275409
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion handler/graphql.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@
import { createHandler } from 'graphql-http/lib/use/@netlify/functions';
import schema from '../lib/schema';

const graphqlHandler = createHandler({ schema: schema.default })

// Create the GraphQL over HTTP native fetch handler
export const handler = createHandler({ schema: schema.default });
export const handler = async (req, ctx) => {
if (req.httpMethod === 'OPTIONS') {
return { statusCode: 200 }
}
return graphqlHandler(req, ctx)
};
1 change: 1 addition & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
for = "/graphql*"
[headers.values]
Access-Control-Allow-Origin = "*"
Access-Control-Allow-Headers = "*"

0 comments on commit 4275409

Please sign in to comment.