Unable to access playground after adding jwt middleware in apollo-server-express

  • just added a jwt validation middleware using app.use() as shown in Setting Up Authentication and Authorization with Apollo Federation - Apollo Blog
  • after adding this middleware i am unable to access graphql playground on the usual endpoint localhost:4000/graphql
  • is this a known issue? does it have a solution?
  • need playground in dev environment so that developers can integrate APIs faster, need to secure it so that it is not open on the public internet

What version of Apollo Server are you using? We changed a lot about how playground (or alternate landing pages) are integrated in AS3.

Sharing a reproduction (eg a repo we can clone) would help a lot too!

1 Like

hi @glasser, thanks for responding!
I have created a reproduction of the gateway server, here is the link to the repo GitHub - jessepinkman9900/apollo-gateway

Hello! I’m not well versed in the ways of jwt, but a potential coarse-grained solution is to not use your checkJwt middleware in local development environments by setting and subsequently checking NODE_ENV in each environment the gateway is running in.

1 Like

It looks like successfully running this reproduction requires me to set a bunch of environment variables like SERVICE_1_ENDPOINT. Can you update the reproduction so it doesn’t require any creativity on my part? (If you can focus entirely on Apollo Server and remove Apollo Gateway entirely, that would help.)

Additionally, this reproduction uses Apollo Server 2. We’ve completely reworked how Playground (or alternative landing pages) integrates with Apollo Server in Apollo Server 3. Can you try upgrading to Apollo Server 3? We’re currently only supporting Apollo Server 2 for security releases.

1 Like