diff --git a/handler/graphql.mjs b/handler/graphql.mjs index 30a8997..8c43a72 100644 --- a/handler/graphql.mjs +++ b/handler/graphql.mjs @@ -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) +}; diff --git a/netlify.toml b/netlify.toml index dcf54dd..58aa14b 100644 --- a/netlify.toml +++ b/netlify.toml @@ -6,3 +6,4 @@ for = "/graphql*" [headers.values] Access-Control-Allow-Origin = "*" + Access-Control-Allow-Headers = "*"