Web server behavior (`index.html`, `/`, etc)

This post has been transferred from spec: web server behavior (`index.html`, `/`, etc) · Issue #61 · webxdc/webxdc_docs · GitHub

This came up after https://github.com/webxdc/store/pull/158#issuecomment-1627378816. Basically the behavior of apps that use things like React/Vue/Solid routers is unreliable (might be broken) because it’s not clearly defined how the webxdc web server works.


The current webxdc implementations (at least Desktop and Android) open the app in such a way that the initial URL is /index.html, not /. This is because of <iframe src="/index.html":

Replacing src = "index.html" with src = "/" should work, as long as the server would respond with the contents of index.html to such a request (currently Delta Chat desktop responds with an error). Most web servers do, like Python’s http.

I believe this started being the case after the WebRTC patches.

non-existent → /index.html

Here are Vue Router docs about how the server needs to be configured for the HTML5 history mode to work properly. It says

If the URL doesn’t match any static assets, it should serve the same index.html page that your app lives in.

Which is a more debatable thing than just the “/” → “/index.html”, but it’s also somewhat less common to encounter a situation where it is useful, at least as of now, because currently you can’t open a webxdc app with a different initial URL. But you can reload a webxdc app, e.g. in Delta Chat desktop, with Ctrl+R (although currently it would just cause it to get closed because of WebRTC mitigation stuff), which would result in a 404 (or is it a network error instead? should we specify this as well?).