How to make a Cross Origin Request work on Android
Hi, there!
I have an HTML Game saved to the internal memory of an Android tablet. I'm trying to run it without leaving Unity using a Webview Plugin from Gree: https://github.com/gree/unity-webview
I've worked most of the details out so far, but I'm stuck with a limitation from Android's side. The game needs to make some Cross Origin Requests, which Android does not allow when you try to access file:// . Instead, I'm requried to use http:// , https:// or data://
08-31 18:35:52.163 20063-20063/com.CompanyName.ProjectName I/chromium﹕ [INFO:CONSOLE(0)] "XMLHttpRequest cannot load file:///storage/emulated/0/Android/data/com.CompanyName.ProjectName/files/GameName/frameworks/cocos2d-html5/moduleConfig.json. Cross origin requests are only supported for protocol schemes: http, data, https.", source:
file:///storage/emulated/0/Android/data/com.CompanyName.ProjectName/files/GameName/index.html (0)
I've worked with two possible solutions:
Creating a Localhost on the application so I can access it using http://
Bypassing the restriction by tricking Android (as mentioned here: http://stackoverflow.com/questions/10620417/access-local-file-in-a-webview)
Still, I wasn't able to figure out how to implement any of these options. Does anyone have ideas on how to go about this? Or perhaps another solution I haven't thought of?
Also, if anyone needs more info, I'd be glad to provide it.
Hi,
I have the same exact problem, did you manage to solve it?
Answer by ProbePLayer · Apr 15, 2018 at 04:29 PM
Maybe this could work If the smartphone browser is chrome? https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi/related?hl=en
Your answer
Follow this Question
Related Questions
Cannot merge android manifests 1 Answer
Unity Android database 0 Answers