求救!umi4 + antd pro过csp策略 #12254
Unanswered
GodYoungHe
asked this question in
Q&A
Replies: 3 comments 4 replies
-
实在是没找到umi哪里能加nonce...希望大家救救孩子... |
Beta Was this translation helpful? Give feedback.
0 replies
-
或者说大佬们有什么更好的办法能过csp吗,不尽感激! |
Beta Was this translation helpful? Give feedback.
0 replies
-
你这不是在加载本地开发的 js 吗,你在开发的时候肯定有代理域名吧,在代理的时候修改下响应头就可以了。 或者在项目根目录创建一个项目级插件 // plugin.ts
import { IApi } from 'umi'
export default (api: IApi) => {
api.onBeforeMiddleware(({ app }) => {
app.use((req, res, next) => {
// res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp')
next()
})
}) 这里面任意改开发服务器的 express 。 |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
如题,现在我开启的csp策略只包含了self,公司不允许用unsafe-inline,于是就想到了加nonce,但是操作了好久好久还是没能成功给style和script加上nonce,大佬们有什么好办法吗~
mf-dep____vendor.5aaccf88.js:290797 Refused to apply inline style because it violates the following Content Security Policy directive: "default-src 'self' 'nonce-c29tZSBjb29sIHN0cmluZyB3aWxsIHBvcCB1cCAxMjM='". Either the 'unsafe-inline' keyword, a hash ('sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'style-src' was not explicitly set, so 'default-src' is used as a fallback.
Beta Was this translation helpful? Give feedback.
All reactions