0

I am trying to create a simple project on android using chatGPT help. According to what it said, I can offload js heavy work into different process, to reduce the UI thread usage. But it seems I keep getting CORS when trying to create new Worker from local worker.js file. I tried the bot's recommendations to give it full url to the local file, or to load it with 'fetch', nothing helps so far.

enter image description here enter image description here enter image description here enter image description here

I know it should work(as I have seen worker works locally same way on another projects). Maybe there's some new settings in recent android versions I need to give any permissions, but chatGPT isn't aware of? Thanks!

Tried some tips chatGPT gave me but nothing really helped.

jub0bs
  • 60,866
  • 25
  • 183
  • 186
Maksim
  • 61
  • 5
  • You write: _I keep getting CORS_. What do you mean by that? Do you get a CORS error? If so, what is the error message? Edit your question and add more details. – jub0bs Apr 01 '23 at 08:55
  • The error appears on 3rd screenshot, but added another one to make it clear. – Maksim Apr 01 '23 at 09:00
  • Please provide enough code so others can better understand or reproduce the problem. – Community Apr 01 '23 at 10:01
  • Does this answer your question? ["physi.js" causes the error: "Script cannot be accessed from origin 'null'"](https://stackoverflow.com/questions/30202529/physi-js-causes-the-error-script-cannot-be-accessed-from-origin-null) – jub0bs Apr 01 '23 at 16:37
  • No, solved it by adding webView.setAllowUniversalAccessFromFileURLs(true). – Maksim Apr 06 '23 at 10:54

1 Answers1

0

solved by adding webView.setAllowUniversalAccessFromFileURLs(true)

Maksim
  • 61
  • 5