Skip to content

getSession() not working in a graphql endpoint with apollo-server-micro #3803

Answered by ephraimduncan
JulianBuse asked this question in Help
Discussion options

You must be logged in to vote

This isn't a next-auth problem. This is related to the Apollo GraphQL Playground. The playground does not send credentials unless explicitly stated with "request.credentials": "include".

const apolloServer = new ApolloServer({
  typeDefs,
  resolvers,
  plugins: [
    ApolloServerPluginLandingPageGraphQLPlayground({
      settings: {
        "request.credentials": "include",
      },
    }),
  ],
  context: async ({ req, res }) => {
    const session = await getSession({ req });

    return { session };
  },
});

Replies: 4 comments 14 replies

Comment options

You must be logged in to vote
2 replies
@Mamsheikh
Comment options

@wessankey
Comment options

Comment options

You must be logged in to vote
3 replies
@vipinlahoti
Comment options

@5starkarma
Comment options

@osvaldovega
Comment options

Answer selected by balazsorban44
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
9 replies
@itzrizvi
Comment options

@gaganbiswas
Comment options

@itzrizvi
Comment options

@gaganbiswas
Comment options

@itzrizvi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
question Ask how to do something or how something works
Converted from issue

This discussion was converted from issue #3801 on February 04, 2022 10:33.