【发布时间】:2021-08-01 18:31:42
【问题描述】:
我已经设置了 apollo-file-upload 并一直在工作,直到我添加了凭据选项以便在浏览器中接受并拥有 cookie,但结果是在 fireFox 中设置的 cookie 崩溃,并且在 chrome 中没有设置 cookie 时崩溃:
阿波罗客户端:
import { createUploadLink } from 'apollo-upload-client'
const link = createUploadLink({
uri: 'http://localhost:4000/graphql',
credentials: 'include'
})
const client = new ApolloClient({
link,
cache: new InMemoryCache()
})
阿波罗服务器:
app.use(session({
store,
name: SESS_NAME,
secret: SESS_SECRET,
resave: false,
saveUninitialized: false,
cookie: {
maxAge: SESS_LIFETIME,
sameSite: 'none',
httpOnly: true
}
}))
const apolloServer = new ApolloServer({
typeDefs,
resolvers,
playground: {
settings: {
'request.credentials': 'include'
}
},
cors: corsOptions,
});
apollo-server 响应错误:
未处理的拒绝(错误):获取失败 46 | // 在给定 GraphQLError 的情况下构造 ApolloError 的实例 47 | // 或网络错误。请注意,其中之一必须是有效的 48 | // 值或构造的错误将毫无意义。
49 |构造函数({ | ^ 50 | graphQLErrors, 51 |网络错误, 52 |错误消息,
【问题讨论】:
标签: reactjs google-chrome cookies file-upload apollo-client