Wednesday, November 2, 2022

[FIXED] How to create a local webserver in cordova android app to use a-frame

Issue

I'm trying to use a-frame in my Cordova android app but when I try to access other local files or https websites I get an error telling me I can't work from file://:

HTML file is currently being served via the file:// protocol. Assets, textures, and models WILL NOT WORK due to cross-origin policy! Please use a local or hosted server

My question is: how can I use a local server in my Cordova app? or are there any alternatives?


Solution

Set a hostname to your app

 <preference name="hostname" value="com.myapp" />

So your content is served over https://com.myapp then you will load from https and not file:// anymore



Answered By - Eric
Answer Checked By - Clifford M. (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.