NodeJS 无法访问Strapi上的管理员

wkftcu5l  于 2023-03-01  发布在  Node.js
关注(0)|答案(1)|浏览(270)

STrapi页面在本地主机上可以正常工作,但当我在replit上托管它时,它会出现这些错误

main.9c01de7f.js:2981 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.9c01de7f.js:2981
main.9c01de7f.js:171 oe
(anonymous) @ main.9c01de7f.js:171
main.9c01de7f.js:3929 Refused to connect to 'http://localhost:1337/admin/init' because it violates the following Content Security Policy directive: "connect-src 'self' https:". 

The code can be seem here https://replit.com/@MAAZ-GAMERGAMER/SelfreliantEdibleDatalog?v=1
dy2hfwbg

dy2hfwbg1#

Strapi在后端强制CSP
在您的simple strapi one client中,在src/utils/api.js中添加以下标题
Content-Security-Policy: connect-src 'self' http://localhost:1337/

import axios from "axios";

const params = {
    headers: {
        Authorization: "bearer " + process.env.REACT_APP_STRIPE_DEV_APP_KEY,
        "Content-Security-Policy": "connect-src 'self' http://localhost:1337;"
    },
};

相关问题