Skip to content

Commit

Permalink
Add check in security middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebodin committed Aug 24, 2022
1 parent 9ad6931 commit fd8e4c6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/core/strapi/lib/middlewares/security.js
Expand Up @@ -35,13 +35,14 @@ module.exports =
(config, { strapi }) =>
(ctx, next) => {
let helmetConfig = defaultsDeep(defaults, config);
const { config: gqlConfig } = strapi.plugin('graphql');
const gqlEndpoint = gqlConfig('endpoint');
const specialPaths = ['/documentation'];

if (
ctx.method === 'GET' &&
[gqlEndpoint, '/documentation'].some((str) => ctx.path.startsWith(str))
) {
if (strapi.plugin('graphql')) {
const { config: gqlConfig } = strapi.plugin('graphql');
specialPaths.push(gqlConfig('endpoint'));
}

if (ctx.method === 'GET' && specialPaths.some((str) => ctx.path.startsWith(str))) {
helmetConfig = merge(helmetConfig, {
contentSecurityPolicy: {
directives: {
Expand Down

0 comments on commit fd8e4c6

Please sign in to comment.