凭证“忽略”和SET-COOKIE标头

时间:2018-06-25 14:09:13

标签: http cookies react-apollo

是否可以将apollo客户端配置为不在每个请求中发送cookie(例如,将凭据设置为omit),并且仍然接受SET-COOKIE标头上来自服务器的cookie?

我的httpLink实现如下:

const httpLink = createHttpLink({
  uri,
  fetch: fetch,
  credentials: 'omit'
});

但是,省略会阻止响应更新cookie。

1 个答案:

答案 0 :(得分:0)

您是否偶然使用ApolloBoostClient?我遇到了同样的问题,stumbling upon this issue可以解决该问题,而是按照建议使用ApolloClient ***:

export const client = new ApolloClient({
  link: createHttpLink({
    credentials: 'include',
    uri: 'http://localhost:8080/api/graphql',
  }),
  cache: new InMemoryCache(),
});`

***除非像您一样,我使用'omit'而不是'include',而是使用ScalaJS而非本机JS

相关问题