The provided middlewares.js code is causing issues during the Docker build process.
Closed this issue ยท 0 comments
xuqssq commented
๐ Bug Report
If after copying the middleware.js code, the Docker build does not work properly and the thumbnails in the Strapi plugin store also fail, this could be due to some configuration errors or environment variables not being set correctly.
#0 0.324 yarn run v1.22.19
#0 0.344 $ strapi build
#0 1.442 [WARN] [@strapi/strapi]: The NODE_ENV is not set to production. This may result in unexpected behavior.
#0 1.493 - Building build context
#0 1.493
#0 1.495 [ERROR] There seems to be an unexpected error, try again with --debug for more information
#0 1.495
#0 1.504 โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโ Error: Could not load js config file /opt/app/config/middlewares.js: โโ Cannot read properties of undefined (reading 'replace') โโ at loadJsFile (/opt/node_modules/@strapi/strapi/dist/core/app-configurat โโ ion/load-config-file.js:18:13) โโ at Module. loadFile (/opt/node_modules/@strapi/strapi/dist/core/app-confi โโ guration/load-config-file.js:37:14) โโ at /opt/node_modules/@strapi/strapi/dist/core/app-configuration/config-l โโ oader.js:14:31 โโ at Array. reduce (<anonymous>) โโ at loadConfigDir (/opt/node_modules/@strapi/strapi/dist/core/app-configu โโ ration/config-loader.js:12:175) โโ at loadConfiguration (/opt/node_modules/@strapi/strapi/dist/core/app-con โโ figuration/index.js:49:42) โโ at new Strapi (/opt/node_modules/@strapi/strapi/dist/Strapi.js:124:23) โโ at Object. initFn [as default] โโ (/opt/node_modules/@strapi/strapi/dist/Strapi.js:467:18) โโ at createBuildContext โโ (/opt/node_modules/@strapi/admin/dist/_chunks/index-sNH2VWbC.js:576:66) โโ at Object. build โโ (/opt/node_modules/@strapi/admin/dist/_chunks/index-sNH2VWbC.js:663:21) โโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
#0 1.530 error Command failed with exit code 1.
#0 1.530 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------
failed to solve: executor failed running [yarn build]: exit code: 1
This is my modified version, it works properly and is the result I expected!
{
name: "strapi::security",
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
"connect-src": ["'self'", "https:"],
"img-src": [
"'self'",
"data:",
"blob:",
"market-assets.strapi.io",
env("CF_PUBLIC_ACCESS_URL") ? env("CF_PUBLIC_ACCESS_URL").replace(/^https?:\/\//, "") : "",
],
"media-src": [
"'self'",
"data:",
"blob:",
"market-assets.strapi.io",
env("CF_PUBLIC_ACCESS_URL") ? env("CF_PUBLIC_ACCESS_URL").replace(/^https?:\/\//, "") : "",
],
upgradeInsecureRequests: null,
},
},
},
},