Nditah
Nditah

Reputation: 1739

Nestjs graphql playground "Server cannot be reached"

I have a v9 Nestjs, graphql that works locally without any issues but when deployed on a digital ocean droplet with nginx, accessing playground says Server cannot be reached. And as such the Schema and Doc tabs on the playground don't load. However, a query or mutation request works. How can I solve this?

enter image description here

enter image description here

I applied cors as shown below but it made no difference

  const app = await NestFactory.create(AppModule, {
    cors: {
      credentials: true,
      origin: ['http://localhost:3000', 'https://api.my-live-server.io'],
    },
  
  });

The related dependencies are:

    "@nestjs/apollo": "10.1.0",
    "@nestjs/graphql": "10.1.2",

Worth-noting that an issue almost similar as asked here on Stackoverflow and the answer pointed to a Github issue that doesn't have exactly the same circumstance and doesn't resolve this.

Upvotes: 2

Views: 1228

Answers (1)

When NODE_ENV is set to production, the boolean value of playground and introspection will be set to false.

Please make sure these values are set to true explicitly.

GraphQLModule.forRoot<ApolloDriverConfig>({
      driver: ApolloDriver,
      autoSchemaFile: true,
      playground: true,// Set this manually if NODE_ENV=production
      introspection: true,//Set this manually if NODE_ENV=production
    }),

Upvotes: 1

Related Questions