Having trouble trying to include cookies in Apollo Sandbox

Hello, I’m trying to include a cookie in my requests, I’ve tried to troubleshoot it by following some of the things I found in this forum and GitHub, but so far I’ve been unsuccessful. If anybody can help my with this I would appreciate it.

Here’s the code for my index.ts file:

import { MikroORM } from "@mikro-orm/postgresql"
import { ApolloServer } from "apollo-server-express"
import connectRedis from "connect-redis"
import dotenv from "dotenv"
import express from "express"
import session from "express-session"
import { createClient } from "redis"
import "reflect-metadata"
import { buildSchema } from "type-graphql"
import { __prod__ } from "./constants"
import mikroConfig from "./mikro-orm.config"
import { PostResolver } from "./resolvers/post"
import { UserResolver } from "./resolvers/user"
import { ApolloContext } from "./types"

async function main() {
  dotenv.config()
  const orm = await MikroORM.init(mikroConfig)
  const emFork = orm.em.fork()
  await orm.getMigrator().up()
  const app = express()

  const corsOptions = {
    credentials: true,
    origin: "https://studio.apollographql.com",
  }

  app.set("trust proxy", !__prod__)

  const RedisStore = connectRedis(session)
  const redisClient = createClient({ legacyMode: true })
  redisClient.connect().catch(console.error)

  app.use(
    session({
      name: "qid",
      store: new RedisStore({ client: redisClient, disableTouch: true }),
      saveUninitialized: false,
      secret: process.env.SESSION_SECRET!,
      resave: false,
      cookie: {
        maxAge: 1000 * 60 * 60 * 24 * 365 * 10, // 10 years
        httpOnly: true,
        sameSite: "none",
        secure: true,
      },
    })
  )

  const apolloServer = new ApolloServer({
    schema: await buildSchema({
      resolvers: [PostResolver, UserResolver],
      validate: false,
    }),
    context: ({ req, res }): ApolloContext => ({ emFork, req, res }),
  })

  await apolloServer.start()
  apolloServer.applyMiddleware({ app, cors: corsOptions })

  app.listen(process.env.PORT, () => {
    console.log("Express server started on port:", process.env.PORT)
  })
}

main()

Here are my Apollo sandbox settings:

image

The console in my dev tools just keeps spamming this, the request for this it contains the cookie, not sure about the meaning of it:

When I try to make a request the cookie doesn’t show up in storage.

I’m not quite sure if you’re using Apollo Server 3 or 4, but with v4 these docs might be helpful in seeing an example. You should be passing the cors options to the app.use.

We have a new Discord Server that we could dive deeper into what is going on here. Feel free to ping me (@watson) if you do join. Hope to see you there!