I'm building a NextJS app, and I'm trying the access a cookie so I can use it to set a Http Header for GraphQL Request, I am using apollo-link-context. This is the code to create the ApolloClient
function createApolloClient(initialState = {}) { const httpLink = new HttpLink({ uri: `${baseUrl}/graphql`, credentials: 'same-origin', fetch }) const authLink = setContext((_, prevCtx) => { let token = '' if (typeof window === 'undefined') token = getCookieFromServer(authCookieName, REQ) else token = getCookieFromBrowser(authCookieName) return ({ headers: { 'Auth-Token': token } }) }) const client = new ApolloClient({ ssrMode: typeof window === 'undefined', cache: new InMemoryCache().restore(initialState), link: authLink.concat(httpLink) }) return client } The issue here is that the getCookieFromServer function expects an Express Request as the second argument, so it can extract the cookie from req.headers.cookie, and I have no idea where I can get it from there.