mirror of
https://github.com/strapi/strapi.git
synced 2025-12-16 09:45:08 +00:00
Merge pull request #14198 from strapi/hotfix/graphql-should-exist
Loading a plugin should always verify its presence
This commit is contained in:
commit
33d0b0c606
@ -27,12 +27,15 @@ function getFiles(ctx) {
|
|||||||
module.exports = (config, { strapi }) => {
|
module.exports = (config, { strapi }) => {
|
||||||
const bodyConfig = defaultsDeep(defaults, config);
|
const bodyConfig = defaultsDeep(defaults, config);
|
||||||
|
|
||||||
|
let gqlEndpoint;
|
||||||
|
if (strapi.plugin('graphql')) {
|
||||||
const { config: gqlConfig } = strapi.plugin('graphql');
|
const { config: gqlConfig } = strapi.plugin('graphql');
|
||||||
const gqlEndpoint = gqlConfig('endpoint');
|
gqlEndpoint = gqlConfig('endpoint');
|
||||||
|
}
|
||||||
|
|
||||||
return async (ctx, next) => {
|
return async (ctx, next) => {
|
||||||
// TODO: find a better way later
|
// TODO: find a better way later
|
||||||
if (ctx.url === gqlEndpoint) {
|
if (gqlEndpoint && ctx.url === gqlEndpoint) {
|
||||||
await next();
|
await next();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -35,13 +35,14 @@ module.exports =
|
|||||||
(config, { strapi }) =>
|
(config, { strapi }) =>
|
||||||
(ctx, next) => {
|
(ctx, next) => {
|
||||||
let helmetConfig = defaultsDeep(defaults, config);
|
let helmetConfig = defaultsDeep(defaults, config);
|
||||||
const { config: gqlConfig } = strapi.plugin('graphql');
|
const specialPaths = ['/documentation'];
|
||||||
const gqlEndpoint = gqlConfig('endpoint');
|
|
||||||
|
|
||||||
if (
|
if (strapi.plugin('graphql')) {
|
||||||
ctx.method === 'GET' &&
|
const { config: gqlConfig } = strapi.plugin('graphql');
|
||||||
[gqlEndpoint, '/documentation'].some((str) => ctx.path.startsWith(str))
|
specialPaths.push(gqlConfig('endpoint'));
|
||||||
) {
|
}
|
||||||
|
|
||||||
|
if (ctx.method === 'GET' && specialPaths.some((str) => ctx.path.startsWith(str))) {
|
||||||
helmetConfig = merge(helmetConfig, {
|
helmetConfig = merge(helmetConfig, {
|
||||||
contentSecurityPolicy: {
|
contentSecurityPolicy: {
|
||||||
directives: {
|
directives: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user