title: How to limit access to my graphql endpoint using Cors or any other node module
body: <p>I'm working on a React/NodeJS, I'm using graphql between the front and the backend.</p>
  
  <p>My frontend PWA application has a link similar to : <a href="https://app.domain.com" rel="nofollow noreferrer">https://app.domain.com</a>.</p>
  
  <p>My backend api has a link similar to : <a href="https://api.domain.com" rel="nofollow noreferrer">https://api.domain.com</a>.</p>
  
  <p>I want to protect my GraphQL endpoint (<a href="https://api.domain.com/graphql" rel="nofollow noreferrer">https://api.domain.com/graphql</a>) from any request call not coming from my PWA Application (<a href="https://app.domain.com" rel="nofollow noreferrer">https://app.domain.com</a>).</p>
  
  <p>Is there any good solution to do that ? using CORS or any other library ?</p>
  
  <p>I did try this in my backend, but still not working :</p>
  
  <pre><code>app.use(cors({origin:'https://app.domain.com'}));
  
  
  //My graphql config
  app.use("/graphql",
    graphqlExpress(req =&gt; ({
      schema: buildSchema(schema),
      rootValue: indexResolver,
      graphiql: true,
      context: { request: req }
    }))
  );
  </code></pre>