0

Currently we have an app contains a webview, in webview the url address is our remote server. Problem is that when start app it will connect to our server to download html/js/css to show content. If network is slow, it will take long time to show a white screen.

For traditional html/css/js, we can just put all the contents in a local folder, then tell webview to load content from that local folder.

But we are using Vue.js. As you may know, even we build Vue.js to /dist folder, you cannot directly use file:// to access them, it must depends on a server.

So my question is: how can we run a small server in iOS/Android app to serve these /dist contents? So that webview can access http://localhost:8080 something to show the content.

Thank you!

2
  • I have exact same requirement. and I am stuck. Did you find any solution for this ? Commented Feb 15, 2023 at 17:54
  • @Nightswatch The only way I think of is to bundle a termux in app and run a nginx server in it. You can google for "termux". Commented Feb 17, 2023 at 1:42

1 Answer 1

1

Webview cannot access localhost. Think about it, webview is running on someone's device, and that device doesn't (and can't ever) know what localhost is. If the http requests in your vue app go out to an actual, live http:// or https:// server, then the vue instantiation will work in a WebView (at least in Android, which is what I know).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.