mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 11:25:17 +00:00
Add check in security middleware
This commit is contained in:
parent
9ad6931823
commit
fd8e4c6bfa
@ -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: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user