title: Authorization header not present in Graphql Request
body: <p>I have a:</p>
  
  <ol>
  <li><p>Frontend: React, Next.js. Uses apollo client. </p></li>
  <li><p>Backend: NodeJs, Express server with a GraphQL endpoint.</p></li>
  </ol>
  
  <p>I apply a cookie to the GraphQL apollo client, here is the code of the instantiation. </p>
  
  <pre><code>  ({ ctx, headers, initialState }) =&gt;
      new ApolloClient({
        uri: "http://localhost:4000/graphql",
        cache: cache,
        credentials: 'include',
        headers: {
        authorization: Cookies.get('token') ? `Bearer ${Cookies.get('token')}` : ""},
        typeDefs,
        resolvers
        }));
  </code></pre>
  
  <p>When I use useQuery in my React component, I send a graphQL request to the backend. I have middleware set up to authenticate the request by checking for the token. The code: </p>
  
  <pre><code>export let checkToken = (req : any, res : any, next : any) =&gt; {
    let token = req.headers['authorization']; // I also tried req.headers.authorization
    if (token.startsWith('Bearer ')) {
      token = token.slice(7, token.length);
    }
  
    if (token) {
      jwt.verify(token, config.cookieKey, (err : any, decoded : any) =&gt; {
        if (err) {
          Logger.info("Token in request is not valid.");
          return res.json({
            success: false,
            message: 'Token is not valid'
          });
        } else {
          Logger.info("Token in request is valid.");
          req.decoded = decoded;
          next();
        }
      });
    } else {
      Logger.info("No token in request found.");
      return res.json({
        success: false,
        message: 'Auth token is not supplied'
      });
    }
  };
  </code></pre>
  
  <p>The issue is that the req.headers.authorization is undefined once it reaches the backend. I have console logged the cookie token before on the client side and it does return a cookie. </p>
  
  <p><strong>CORS EDIT</strong></p>
  
  <pre><code> app.use(function(_req, res, next) {
        res.header("Access-Control-Allow-Origin", `${config.frontend_url}`);
        res.header('Access-Control-Allow-Methods', "GET,HEAD,OPTIONS,POST,PUT");
        res.header("Access-Control-Allow-Credentials", "true");
        res.header('Access-Control-Allow-Headers', "Access-Control-Allow-Origin, Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers, Authorization");
        next();
      });
  </code></pre>
  
  <p><strong>Console.log(req.headers) edit</strong></p>
  
  <pre><code>{ accept: '*/*',
    'content-type': 'application/json',
    authorization: '',
    'content-length': '185',
    'user-agent': 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)',
    'accept-encoding': 'gzip,deflate',
    connection: 'close',
    host: 'localhost:4000' }
  
  { accept: '*/*',
    'content-type': 'application/json',
    authorization: '',
    'content-length': '185',
    'user-agent': 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)',
    'accept-encoding': 'gzip,deflate',
    connection: 'close',
    host: 'localhost:4000' }
  </code></pre>