Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Usage of helmet in default configuration blocks graphql playground to open

Tags:

graphql

app.use(xss());//safety against XSS attack or Cross Site Scripting attacks

app.use(helmet());
httpServer.listen(process.env.PORT || 4000, () => {
      console.log(
        `🚀 Server ready at http://localhost:${process.env.PORT || 4000}${
          server.graphqlPath
        `🚀 Server ready at http://localhost:${process.env.PORT || 4000}${server.graphqlPath
        }`
      );
      console.log(
        `🚀 Subscriptions ready at ws://localhost:${process.env.PORT || 4000}${
          server.subscriptionsPath
    
        }`
      );
    });

I am using graphQL and helmet at the same time. I think which is stopping my graphQL api playground. THIS MY CODE I CANT RESOLVE PLS HELP. enter image description here

like image 953
Shresth Bharadia Avatar asked Sep 03 '25 05:09

Shresth Bharadia


1 Answers

hey shresth try using this in your program

app.use(helmet({ contentSecurityPolicy: (process.env.NODE_ENV === 'production') ? undefined : false })); 
like image 198
Yasharth Dubey Avatar answered Sep 05 '25 01:09

Yasharth Dubey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!