Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'Access-Control-Request-Headers' of undefined #2509

Closed
incompletude opened this issue Mar 28, 2019 · 0 comments
Closed

Comments

@incompletude
Copy link

incompletude commented Mar 28, 2019

I have found this issue, related to mine, but I could not found a solution to my problem.

#1560

serverless.yml:

service: graphql-aws

provider:
  name: aws
  runtime: nodejs8.10
functions:
  graphql:
    handler: graphql.graphqlHandler
    environment:
      SLS_DEBUG: true
    events:
      - http:
          path: graphql
          method: post
          cors: true
          integration: lambda-proxy
      - http:
          path: graphql
          method: get
          cors: true
          integration: lambda-proxy

graphql.js:

const { ApolloServer, gql } = require('apollo-server-lambda')

const typeDefs = gql`
  type Query {
    hello: String
  }
`

const resolvers = {
  Query: {
    hello: () => 'Hello world!',
  },
}

const server = new ApolloServer({ typeDefs, resolvers })

exports.graphqlHandler = server.createHandler({
  cors: {
    origin: '*',
    credentials: true,
  },
})

Test:

serverless invoke local --function graphql --data '{ "httpMethod": "POST", "body": { "query": "{ hello }" }}'

Error:

Cannot read property 'Access-Control-Request-Headers' of undefined

Can someone help me solving this?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant