Srihari Balgam
Srihari Balgam

Reputation: 1

‘file://’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check:

I am using ionic3 for my application development. I am getting the below error for the first time installation of my Android application. Then, after re-launching, the app is working correctly.

I'm seeing this issue only on a new/fresh install of the app. Restarting the app resolves the issue, which is strange.

I have been seeing this issue after I set targetSdkVersion 28 i.e, building app for Android 9 pie.

Access to XMLHttpRequest at ‘the url’ from origin ‘file://’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource’.

My App Configuration:

enter image description here

Upvotes: 0

Views: 904

Answers (2)

Avishai Peretz
Avishai Peretz

Reputation: 38

Try to convert your path by this way

this.file = (<any>window).Ionic.WebView.convertFileSrc(fileSrc)

Upvotes: 0

alemp
alemp

Reputation: 21

This is happening because of a new WebView update: 76.0.3809.89

There's a known bug from Android.

The fix (version 76.0.3809.111) has started to be rolled out.

I hope this helps.

Upvotes: 1

Related Questions