Android: /wails/* assets served with Content-Type application/json breaks runtime JS modules (screen resets on first interaction)
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 36.3k
- Forks
- 1.9k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 33
Description
Summary
On Android (Wails v3.0.0-beta.12), the runtime JS modules under /wails/ are served with a hardcoded Content-Type: application/json instead of a JS MIME type. Chromium's WebView refuses to execute a <script type="module"> served with a non-JS MIME type, so import { Call } from '/wails/runtime.js' never runs — the entire frontend stays dead, and native form submits trigger a page reload (the screen visually "resets" to its initial state on first interaction).
Root cause
In MainActivity.shouldInterceptRequest, the branch that handles /wails/* always sets:
headers.put("Content-Type", "application/json");
This is applied to every /wails/* response, including the runtime JS modules (runtime.js, transport.js). The regular asset path handler (WailsPathHandler, which resolves MIME via getMimeTypeForPath in application_android.go) correctly maps .js → application/javascript, but the /wails/* intercept path bypasses it entirely.
Reproduction
- Build any Wails v3 Android app (frontend uses
import ... from '/wails/runtime.js'). - Run on a device or emulator.
- In logcat, Chromium reports the module script is rejected because of a non-JS MIME type.
- The app's own module script (
app.js) fails to load, forms fall back to native submission, and the page reloads.
Suggested fix
Detect the file extension in shouldInterceptRequest and return a JS MIME type for .js/.mjs:
String mimeType = fullPath.endsWith(".js") || fullPath.endsWith(".mjs")
? "application/javascript"
: "application/json";
headers.put("Content-Type", mimeType);
Workaround
Patch the generated MainActivity.java in the Android overlay with the extension-based MIME above.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in MainActivity.shouldInterceptRequest and compare its /wails/* response handling with WailsPathHandler and getMimeTypeForPath in application_android.go. Reproduce on an Android device or emulator, inspect logcat, and verify that runtime.js and transport.js load as JavaScript modules without the frontend resetting on interaction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, go, java
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100