我有一个用 ReactJS 编写的 Web 应用程序,并使用 NextJS 呈现服务器。它在所有浏览器上都可以正常工作,但是当我在 Android webView 中打开它时,我的所有请求都被阻止,原因是“csp:blocked”,如下面的屏幕截图所示。
我没有指定我自己的任何 CSP 策略。
这是我的 next.config
/**
* Disable public routes from "pages" folder.
*/
useFileSystemPublicRoutes: false,
/**
* Change "__next" directory path.
*/
assetPrefix: '/store/__js',
webpack: (config) => {
config.output.publicPath = `/store/__js${config.output.publicPath}` // eslint-disable-line no-param-reassign
return config
},
最佳答案
面对完全相同的问题,您需要在 Android 端对 WebView 设置进行一些更改。
WebSettings webSettings = yourWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
yourWebView.loadUrl("yourWebUrl");
关于android - 被阻止 :csp in Android webView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55074869/