React Apollo Client not sending cookies

后端 未结 3 1678
隐瞒了意图╮
隐瞒了意图╮ 2021-01-19 12:24

I have tried following the instructions on Apollo Client for sending cookies along with the graphql request, but the express server is not receiving any cookies and when I i

3条回答
  •  天命终不由人
    2021-01-19 12:36

    I do not understand this why the documentation says what it does, although perhaps a developer with more experience would not have had a problem.

    Anyway, the less experienced developer should note that instead of:

    const link = createHttpLink({
      uri: 'http://localhost:3000/api/graphql',
      opts: {
        credentials: 'include',
      }
    });
    

    It should just be:

    const httpLink = createHttpLink({
      uri: 'http://localhost:3000/api/graphql',
      credentials: 'same-origin'
    });
    

    In other words, there is no separate opts object within the createHttpLink configuration object.

提交回复
热议问题