You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From conversation with someone trying to integrate the app, realized that the Next.js API doesn't have CORS enabled.
To fix this, /pages/api/graphql.ts needs to updated with:
// Make sure to "yarn add cors" or "npm i cors"importCORSfrom'cors'constapolloServer=newApolloServer({ typeDefs, resolvers })constcors=CORS({origin: "*"})
functionrunMiddleware(req,res,fn){returnnewPromise((resolve,reject)=>{fn(req,res,(result)=>{if(resultinstanceofError)returnreject(result)returnresolve(result)})})}exportdefaultasyncfunctionhandler(req,res){// Set CORS headers to allow all originsawaitrunMiddleware(req,res,cors)// Create and run GQL handlerconstgraphql=apolloServer.createHandler({path: "/api/graphql"})returngraphql(req,res)}
The text was updated successfully, but these errors were encountered:
From conversation with someone trying to integrate the app, realized that the Next.js API doesn't have CORS enabled.
To fix this,
/pages/api/graphql.ts
needs to updated with:The text was updated successfully, but these errors were encountered: