New HTML2EXE APIs: App Version and Request Header Injection
Two practical APIs were recently added to HTML2EXE. You can now read the packaged app version at runtime and inject custom HTTP headers for matched requests.
New APIs Overview
window.HTMLPackHelper.getVersion()window.HTMLPackHelper.setRequestHeaders(urlPattern, headers)window.HTMLPackHelper.removeRequestHeaders(urlPattern)
1) App Version API: getVersion
What it does
Returns the app version configured during packaging.
Common use cases
- Show the current version in an About page.
- Send version info in logs for easier issue diagnosis.
- Compare with server-side latest version and show update tips.
Example
const version = window.HTMLPackHelper.getVersion();
console.log('Current app version:', version);
// If version is not configured, it returns "1.0.0.0" by default.
2) Request Header API: setRequestHeaders
What it does
Adds custom HTTP headers to requests that match a URL pattern.
Common use cases
- Attach
Authorizationtokens to API requests. - Add channel/source headers such as
X-Channel. - Append client version (
X-App-Version) for backend analytics and compatibility checks.
Example: add headers
window.HTMLPackHelper.setRequestHeaders('https://api.example.com/*', {
Authorization: 'Bearer your-token',
'X-Channel': 'html2exe-client',
'X-App-Version': window.HTMLPackHelper.getVersion(),
});
Example: remove headers
window.HTMLPackHelper.removeRequestHeaders('https://api.example.com/*');
Recommended Integration Pattern
Read version once during app startup, then inject it into request headers:
const appVersion = window.HTMLPackHelper.getVersion();
window.HTMLPackHelper.setRequestHeaders('https://api.example.com/*', {
'X-App-Version': appVersion,
});
Notes
- These APIs are available only when API support is enabled during packaging.
- Keep
urlPatternscoped to your target domain to avoid unintended side effects. - Remove unused header rules with
removeRequestHeaderswhen they are no longer needed.