在数字海洋液滴中部署strapi的错误:因为它违反了以下内容安全策略指令:'connect-src' self' https:

发布于 2025-01-27 06:40:16 字数 2740 浏览 4 评论 0原文

我是数字海洋的新手,并部署了Strapi进行生产。

我设法创建了一个运行Ubuntu 20的新的数字海洋液滴,并在其中安装了节点JS。我还安装了NGINX,尽管我怀疑此时是否正确使用了它。

在任何情况下,我都设法修复了与Strapi应用程序相关的所有错误,并且我设法使Strapi在液滴的端口1337上运行。 NGINX服务器正在使用默认端口80。 http://137.184.181.149:80 Strapi在端口1337

http://137.184.184.181.149:149:149:1337:1337:1337:1337:1337:1337:1337:1337:1337:

您可以看到如果您单击上面的链接并检查控制台日志,则实际错误。

控制台日志显示:

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

(anonymous) @ main.25315363.js:7519
M.exports @ main.25315363.js:7519
M.exports @ main.25315363.js:7519
Promise.then (async)
r.request @ main.25315363.js:7519
r.<computed> @ main.25315363.js:7519
(anonymous) @ main.25315363.js:7519
(anonymous) @ main.25315363.js:7776
(anonymous) @ main.25315363.js:7776
Sc @ main.25315363.js:7776
(anonymous) @ main.25315363.js:7776
76442 @ main.25315363.js:7776
s @ runtime~main.1ecd9f7d.js:1
h @ main.25315363.js:7909
(anonymous) @ main.25315363.js:7909
r @ runtime~main.1ecd9f7d.js:2
(anonymous) @ main.25315363.js:1
main.25315363.js:7776 Error: Network Error
    at M.exports (main.25315363.js:7519:7821)
    at XMLHttpRequest.E.onerror (main.25315363.js:7519:2814)
(anonymous) @ main.25315363.js:7776
tn @ main.25315363.js:7776
Promise.then (async)
Yt @ main.25315363.js:7776
(anonymous) @ main.25315363.js:7776
Sc @ main.25315363.js:7776
(anonymous) @ main.25315363.js:7776
76442 @ main.25315363.js:7776
s @ runtime~main.1ecd9f7d.js:1
h @ main.25315363.js:7909
(anonymous) @ main.25315363.js:7909
r @ runtime~main.1ecd9f7d.js:2
(anonymous) @ main.25315363.js:1
main.25315363.js:7502 Refused to connect to 'http://localhost:1337/admin/init' because it violates the following Content Security Policy directive: "connect-src 'self' https:".

$.default @ main.25315363.js:7502
(anonymous) @ 6706.b0b5124d.chunk.js:16
(anonymous) @ 6706.b0b5124d.chunk.js:16
Jt @ 6706.b0b5124d.chunk.js:16
(anonymous) @ 6706.b0b5124d.chunk.js:16
(anonymous) @ 6706.b0b5124d.chunk.js:16
Uc @ main.25315363.js:7589
h.unstable_runWithPriority @ main.25315363.js:7621
Vi @ main.25315363.js:7585
fu @ main.25315363.js:7589
(anonymous) @ main.25315363.js:7589
k @ main.25315363.js:7621
x.port1.onmessage @ main.25315363.js:7621
main.25315363.js:7502 Refused to connect to 'http://localhost:1337/admin/init' because it violates the document's Content Security Policy.

我在做什么错? 如何解决这个问题? 我想通过IP地址,甚至通过我分配的域访问我的

Strapi

应用Nginx的文件夹之一???

I am new to Digital Ocean and deploying strapi for production.

I have managed to create a new Digital Ocean droplet running Ubuntu 20 and I have installed node js in it. I also installed nginx although I doubt if I'm using it correctly at this point.

In any case I managed to fix all the errors that are related to the strapi application and I have managed to get strapi to run on port 1337 of the droplet. The default port 80 is being used by the nginx server. http://137.184.181.149:80
and strapi is running on port 1337

http://137.184.181.149:1337/admin

You can see the actual error if you click on the above link and check the console logs.

Console logs display:

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

(anonymous) @ main.25315363.js:7519
M.exports @ main.25315363.js:7519
M.exports @ main.25315363.js:7519
Promise.then (async)
r.request @ main.25315363.js:7519
r.<computed> @ main.25315363.js:7519
(anonymous) @ main.25315363.js:7519
(anonymous) @ main.25315363.js:7776
(anonymous) @ main.25315363.js:7776
Sc @ main.25315363.js:7776
(anonymous) @ main.25315363.js:7776
76442 @ main.25315363.js:7776
s @ runtime~main.1ecd9f7d.js:1
h @ main.25315363.js:7909
(anonymous) @ main.25315363.js:7909
r @ runtime~main.1ecd9f7d.js:2
(anonymous) @ main.25315363.js:1
main.25315363.js:7776 Error: Network Error
    at M.exports (main.25315363.js:7519:7821)
    at XMLHttpRequest.E.onerror (main.25315363.js:7519:2814)
(anonymous) @ main.25315363.js:7776
tn @ main.25315363.js:7776
Promise.then (async)
Yt @ main.25315363.js:7776
(anonymous) @ main.25315363.js:7776
Sc @ main.25315363.js:7776
(anonymous) @ main.25315363.js:7776
76442 @ main.25315363.js:7776
s @ runtime~main.1ecd9f7d.js:1
h @ main.25315363.js:7909
(anonymous) @ main.25315363.js:7909
r @ runtime~main.1ecd9f7d.js:2
(anonymous) @ main.25315363.js:1
main.25315363.js:7502 Refused to connect to 'http://localhost:1337/admin/init' because it violates the following Content Security Policy directive: "connect-src 'self' https:".

$.default @ main.25315363.js:7502
(anonymous) @ 6706.b0b5124d.chunk.js:16
(anonymous) @ 6706.b0b5124d.chunk.js:16
Jt @ 6706.b0b5124d.chunk.js:16
(anonymous) @ 6706.b0b5124d.chunk.js:16
(anonymous) @ 6706.b0b5124d.chunk.js:16
Uc @ main.25315363.js:7589
h.unstable_runWithPriority @ main.25315363.js:7621
Vi @ main.25315363.js:7585
fu @ main.25315363.js:7589
(anonymous) @ main.25315363.js:7589
k @ main.25315363.js:7621
x.port1.onmessage @ main.25315363.js:7621
main.25315363.js:7502 Refused to connect to 'http://localhost:1337/admin/init' because it violates the document's Content Security Policy.

What am I doing wrong?
How to fix this?
I would like to access my strapi app via the IP address and perhaps even through a domain I assign....

Currently the strapi app is on the home folder /~

Should I be putting the strapi app inside one of the folders of nginx???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听,心雨的声音 2025-02-03 06:40:16

您是否尝试删除Strapi .Cache文件夹?

您还可以在Strapi配置文件中检查主机,
我的在这里:config/server.js

Did you try to delete the strapi .cache folder ?

You can also check for the host in the strapi config file,
mine is here: config/server.js

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文