android-js / androidjs

Platform to build android app using node js
MIT License
462 stars 109 forks source link

CORS Error when using Fetch in JS. #268

Closed ftk789 closed 1 year ago

ftk789 commented 1 year ago

Describe the bug When using Fetch, It gives CORS error in Chrome on PC, Now fixing it would be running Chrome with no flag and CORS disabled, To Reproduce Steps to reproduce the behavior:

  1. Use fetch

Expected behavior Fetch a local file.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context When using Fetch, it gives CORS problem, Keep in mind I'm Fetching a local file like " Test.txt", Now when building the app, I have no clue how to allow the apk to Fetch the local file, Because i'm sure in the background it gives the CORS error as well, So yea.

Zebraslive commented 1 year ago

I have the same issue. This is the only thing preventing me from continuing to build my app.

In order to fix this someone would need to implement an api to disable CORS on the android.js webview.

something like app.disableCORS(true);

but i doubt they will add this ability anytime soon.

ftk789 commented 1 year ago

@Zebraslive , Apparently, It's fixable by using fetch with this: fetch("Something",{ origin:'*', })