wailsapp / wailsapp/wails

Android: /wails/* assets served with Content-Type application/json breaks runtime JS modules (screen resets on first interaction)

Open Beginner friendly
#6,014 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug v3
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 .jsapplication/javascript, but the /wails/* intercept path bypasses it entirely.

Reproduction
  1. Build any Wails v3 Android app (frontend uses import ... from '/wails/runtime.js').
  2. Run on a device or emulator.
  3. In logcat, Chromium reports the module script is rejected because of a non-JS MIME type.
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.