After adding a custom plugin to my Strapi project, trying to access Strapi admin in production causes the following error:
Refused to connect to ‘http://localhost:1337/admin/init’ because it violates the following Content Security Policy directive: “connect-src ‘self’ https:”.
It worked fine before adding this plugin, so that’s why I assume there’s something in my plugin (or something I missed), causing the issue. The plugin was created using Strapis plugin generator with the typescript option, it still has the placeholder admin pages generated by Strapi. The plugin functionality is in a service used by a cron task.
I read that it might be something to do with the admin not being built, but I’m pretty sure it is. Initially the server wouldn’t start until I added a prebuild script to my package.json like this:
"scripts": {
"develop": "strapi develop",
"start": "node node_modules/@strapi/strapi/bin/strapi.js start",
"build": "strapi build",
"prebuild": "cd src/plugins/my-plugin && npm run build",
"strapi": "strapi"
},
I haven’t changed the middleware-plugin or any policies, but maybe I have to?
I realize this is quite vague, but I’m posting in hope that someone might recognize the issue and know what I might be missing.
System Information
- Strapi Version: 4.10.6
- Node Version: 16