我一直在努力尝试在我的 Ubuntu 服务器上安装 Strapi 几个小时。
Ubuntu: 20.04
nodejs: v14.19.0
npm: 6.14.16
strapi: 4
npx create-strapi-app@latest my-project --quickinstall
所有的安装过程都是无缝的,但是当我去 http://mydomain:1337/admin 以创建第一个用户时,我收到了这个警告:an error occurred while requesting the API.
我知道这个问题已经遇到过好几次了,但到目前为止,没有一个建议的解决方案对我有帮助。
我也在 Chrome 控制台中发现了这个错误,但我不确定它是否与我的问题有关:
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:".
任何想法 ?
最佳答案
您需要构建应用程序。 Read this github issue
运行:npm run build
或 yarn build
或 strapi build
取决于您使用的是什么
关于node.js - Strapi:警告请求 API 时发生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70957481/