Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strapi: Warning an error occurred while requesting the API

I've been struggling for hours trying to install Strapi on my Ubuntu server.

Ubuntu: 20.04
nodejs: v14.19.0
npm: 6.14.16
strapi: 4

npx create-strapi-app@latest my-project --quickinstall

All the installation process goes seamlessly but when I go to http://mydomain:1337/admin in order to create a first user I get this warning:

an error occurred while requesting the API.

I know this problem has been encountered several times but none of the suggested solutions have helped me so far. I also found this error in the Chrome console but I'm not not sure it's related to the my problem:

main.815f1087.js:2 Refused to connect to 'http://localhost:1337/admin/project-type' because it violates the following Content Security Policy directive: "connect-src 'self' https:".

Any idea ?

like image 428
Duddy67 Avatar asked Dec 02 '25 16:12

Duddy67


2 Answers

You need to build the app. Read this github issue

Run: npm run build or yarn build or strapi build depending on what you are using

like image 121
Kholdarbekov Avatar answered Dec 06 '25 08:12

Kholdarbekov


I had this error after upgrading to latest Strapi and all dependencies, what helped me, is to rebuild the Strapi admin interface:

yarn build

or

npm run build

then start develop

yarn develop

or

npm run develop
like image 31
atazmin Avatar answered Dec 06 '25 08:12

atazmin