Reactjs 未使用apollo客户端、apollo服务器和express会话设置Cookie
我正在尝试使用快速会话在登录时初始化cookie,但它似乎只在我从同一个站点请求时起作用 阿波罗客户:Reactjs 未使用apollo客户端、apollo服务器和express会话设置Cookie,reactjs,cookies,apollo-client,apollo-server,express-session,Reactjs,Cookies,Apollo Client,Apollo Server,Express Session,我正在尝试使用快速会话在登录时初始化cookie,但它似乎只在我从同一个站点请求时起作用 阿波罗客户: const endPoint = createUploadLink({ uri: 'http://localhost:4000/graphql' }) const client = new ApolloClient({ link: endPoint, credentials: 'include', cache: new InMemoryCache(), })
const endPoint = createUploadLink({
uri: 'http://localhost:4000/graphql'
})
const client = new ApolloClient({
link: endPoint,
credentials: 'include',
cache: new InMemoryCache(),
})
阿波罗服务器:
const corsOptions = {
origin: "http://localhost:3000",
credentials: true,
allowedHeaders: ['Content-Type', 'Authorization']
}
app.use(session({
name: 'foo',
secret: 'bar',
resave: false,
saveUninitialized: false,
cookie: {
maxAge: 360000,
sameSite: 'none',
httpOnly: true
}
}))
const apolloServer = new ApolloServer({
typeDefs,
resolvers,
playground: {
settings: {
'request.credentials': 'include'
}
},
cors: corsOptions
});
现在,如果请求是通过graphql发出的,则会设置cookie,但如果登录请求是从localhost:3000发出的,并且会话已初始化,则不会设置cookie
求求你,我在这里失踪了