在 Android 网络视图中获取 blocked:csp

Getting blocked:csp in Android webView

我有一个用 ReactJS 编写并使用 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");