Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting blocked:csp in Android webView

I have a web app that is written in ReactJS and server rendered using NextJS. It works fine on all browsers but when I open it in Android webView, all my requests are blocked citing the reason "csp:blocked" as shown in the screenshot below.

I haven't specified any CSP policy of my own.

Here's my 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
},

csp:blocked in Android webView for web app written in NextJS

like image 886
Ajay Poshak Avatar asked Oct 26 '25 10:10

Ajay Poshak


1 Answers

Faced exactly the same issue, you need to do some changes in WebView settings on Android side.

WebSettings webSettings = yourWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
yourWebView.loadUrl("yourWebUrl");
like image 168
mohit kejriwal Avatar answered Oct 28 '25 23:10

mohit kejriwal