Changing a web build from base: '/' to base: './' fixed the asset requests in our nested-path test. It did nothing to the application's fetch('/api/status') call.
That distinction matters when moving a web frontend into a mini app runtime. The build system can relocate files it understands. It cannot infer where your business backend should be, how the user gets a session or which native functions the host has exposed.
We built the same small web project twice and inspected the outputs and their HTTP requests. The result offers a useful first check for a packaged-web migration: separate the contract for loading the application from the contract for using its services.
First, distinguish a web build from H5 packaging
FinClip has an H5 Application format for running packaged web projects within its SDK. It does not require rewriting them into ordinary mini program syntax. The application has a configurable entry directory and file. FinClip supplies the runtime, tools and management platform; the application team still owns its frontend, backend and integration with the host. H5 Application guide.
There are therefore two different operations to consider. Your web toolchain produces deployable HTML, JavaScript, styles and assets. FinClip's H5 delivery path packages the web application for its runtime. Successfully completing the first does not validate the second.
The experiment below covers the first operation and its output contracts. It uses actual production builds and HTTP requests to local files. It is not a FinClip simulator or mobile-runtime test, and the chosen nested URL is a test fixture rather than a claim about FinClip's internal directory layout.
The project and the two builds
We used Node.js 24.22.3 and Vite 8.4.1. The project contains an HTML entry, a stylesheet, an entry module and a lazily imported module. A separate button requests an API. There is no backend and no production service involved.
The source entry is deliberately ordinary:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Package contract probe</title>
</head>
<body>
<main>
<h1>Package contract probe</h1>
<p id="status">Ready</p>
<button id="load-detail">Load local module</button>
<button id="check-api">Check API</button>
</main>
<script type="module" src="./main.js"></script>
</body>
</html>
The entry module, main.js, imports both a stylesheet and a module used after interaction:
import './style.css';
document.querySelector('#load-detail').addEventListener('click', async () => {
const { detail } = await import('./detail.js');
document.querySelector('#status').textContent = detail;
});
document.querySelector('#check-api').addEventListener('click', async () => {
const response = await fetch('/api/status');
document.querySelector('#status').textContent = String(response.status);
});
The remaining files are small:
// detail.js
export const detail = 'This text comes from a separately built local JavaScript module.';
/* style.css */
body { font: 18px system-ui, sans-serif; margin: 3rem; color: #12304a; }
button { margin-right: 1rem; padding: 0.6rem 1rem; }
Install the pinned tool and build twice from this source directory, using different output locations:
npm install --save-dev --save-exact vite@8.4.1
npx vite build --base=/ --outDir=dist-absolute
npx vite build --base=./ --outDir=dist-relative
Vite's documented base setting adjusts generated asset references. A relative base makes those references relative to their files. It is not a general rewrite rule for every URL string in application code. Vite production build documentation.
What the generated files actually showed
Both builds produced four files: an HTML entry, a CSS file, the main JavaScript chunk and the lazy JavaScript chunk. The HTML and main JavaScript differed. The CSS and lazy-module contents had identical SHA-256 hashes between builds.
The entry documents showed the immediately relevant difference:
<!-- base: '/' -->
<script type="module" crossorigin src="/assets/index-BElgYttY.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DHEgbG5-.css">
<!-- base: './' -->
<script type="module" crossorigin src="./assets/index-u44pn5Ki.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-DHEgbG5-.css">
These are observed filenames from this run, not names to hardcode into a deployment. A change to the source or build tool can produce different hashes.
We then served each output in two ways. The first mount placed its files at /. The second exposed them only beneath /package/demo/. For each entry, the test read the script and stylesheet references, resolved them against the entry URL and made real HTTP requests.
| Build | Test mount | Entry HTML | Referenced JS and CSS |
|---|---|---|---|
| Absolute base | / |
200 | Both 200 |
| Relative base | / |
200 | Both 200 |
| Absolute base | /package/demo/ |
200 | Both 404 |
| Relative base | /package/demo/ |
200 | Both 200 |
The absolute build still requested /assets/... from the server root. The relative build requested files under /package/demo/assets/..., where they were available. This follows standard URL resolution: a leading slash resolves from the origin root, while a relative reference resolves against the base directory. MDN URL constructor.
This check proves that the entry's two resource references resolve to available files under the selected mounts. It does not prove that the JavaScript executed, that the lazy module loaded on interaction or that a target mobile web engine supports the resulting code. Those need execution tests.
The API call survived both builds unchanged
Both generated main chunks retained /api/status.
The local HTTP test resolved that reference to the server's /api/status path in all four cases. The probe constructed this request in Node from the unchanged URL literal; it did not execute the application's fetch handler. All four requests returned 404 because the fixture intentionally contained no API. Changing the asset base never supplied one.
On a website, this relative request may rely on a reverse proxy. The frontend reaches its own origin, and the server routes the request elsewhere. The application source contains no evidence of that routing arrangement. Move only the files, and the arrangement stays behind.
FinClip documents a more specific rule for H5 applications: under their internal protocol, relative requests are handled as local file requests. External services require complete URLs. That is a documented runtime contract, separate from the HTTP behaviour measured above. H5 Application FAQ.
An adaptation might therefore make the service endpoint explicit:
const API_BASE = 'https://api.example.com/';
const endpoint = new URL('api/status', API_BASE);
const response = await fetch(endpoint);
api.example.com is a placeholder. This example only makes URL construction explicit; it does not implement authentication, authorisation or a tested FinClip network integration. Those are separate parts of the application contract.
The engineering lesson is useful beyond this runtime. A build can relocate static assets while leaving a hidden dependency on the original web server completely intact.
Entry points and host APIs need their own decisions
After inspecting the build, identify exactly which directory contains the deliverable and which HTML file starts it. FinClip exposes these choices through miniprogramRoot and entryFile. Pointing at source files that still require a development server is different from pointing at the production output.
A mobile host also has its own interaction model. Browser history, application navigation and closing the hosted experience are not automatically the same operation. Check how the service enters and exits before assuming its existing router supplies the complete experience.
Treat host access explicitly too. A web application cannot infer a native capability from the fact that it is packaged. FinClip's H5 FAQ specifies loadExtApi for custom API registration and states that the FinClipConf.js configuration route does not apply to H5 applications. Custom APIs for H5.
An integration review should name each required host operation, its expected inputs and outputs, its failure response and the versions on which it has been checked. That is more informative than reporting that a bridge object exists.
Include the bundled runtime dependency in release records
The H5 base library travels with the packaged application. FinClip documents repackaging and uploading to pick up new features, rather than assuming the online base-library version controls an existing H5 package. H5 packaging and maintenance.
That makes the release record broader than a source commit. It should identify the frontend build, the packaging tool, the bundled dependency and the host environment tested. When behaviour differs between two installations, these records help the team compare actual inputs instead of assuming the same application version means every dependency is identical.
The next validation step is to package the production output in the intended Studio environment, inspect the resulting entry and resources, then test it in a host containing the target SDK. Studio's guide distinguishes simulator work from device preview; one should not be reported as the other. FinClip Studio guide.
Our run stopped before that stage. It produced and inspected web builds; it did not establish a working FinClip package or mobile integration.
The decision is about dependencies, not file extensions
A web frontend can be a good candidate for packaged delivery when its deployable files and service connections are clear. The actual adaptation work becomes visible once the team distinguishes local resources, remote services and host functions.
In this experiment, one build setting fixed a demonstrable asset-path problem. The same change left the API assumption untouched. That is precisely why a successful build is a starting point for migration analysis, rather than evidence that migration is complete.
Before deciding to keep a service hosted, package it as H5 or rebuild it as an ordinary mini app, inspect those three dependency groups. Preserve the implementation where its assumptions still hold. Change the contracts where the execution environment has changed.
Reproduce the HTTP checks
After the two build commands above, save the following as check-output.mjs next to the output directories. It needs only Node's built-in modules. The server exposes files on the loopback interface and deliberately supplies no API or history fallback.
import { readFile } from 'node:fs/promises';
import { resolve, sep } from 'node:path';
import { createServer } from 'node:http';
import assert from 'node:assert/strict';
const outputs = process.argv.slice(2);
assert.equal(outputs.length, 2, 'Pass the absolute-base and relative-base output directories.');
const rows = [];
for (const [index, directory] of outputs.entries()) {
const root = resolve(directory);
const html = await readFile(resolve(root, 'index.html'), 'utf8');
const refs = [...html.matchAll(/(?:src|href)="([^"]+\.(?:js|css))"/g)].map(m => m[1]);
assert.equal(refs.length, 2);
assert(refs.some(ref => ref.endsWith('.js')) && refs.some(ref => ref.endsWith('.css')));
for (const mount of ['/', '/package/demo/']) {
const server = createServer(async (request, response) => {
const pathname = new URL(request.url, 'http://localhost').pathname;
if (!pathname.startsWith(mount)) return response.writeHead(404).end();
const file = resolve(root, pathname.slice(mount.length) || 'index.html');
if (!file.startsWith(root + sep)) return response.writeHead(403).end();
try { const bytes = await readFile(file); response.writeHead(200).end(bytes); }
catch { response.writeHead(404).end(); }
});
await new Promise(done => server.listen(0, '127.0.0.1', done));
const entry = `http://127.0.0.1:${server.address().port}${mount}index.html`;
try {
const status = async url => {
const response = await fetch(url);
await response.arrayBuffer();
return response.status;
};
const entryStatus = await status(entry);
const assets = await Promise.all(refs.map(ref => status(new URL(ref, entry))));
const apiStatus = await status(new URL('/api/status', entry));
assert.equal(entryStatus, 200);
assert(assets.every(s => s === (index === 0 && mount !== '/' ? 404 : 200)));
assert.equal(apiStatus, 404);
rows.push({ build: index === 0 ? 'absolute' : 'relative', mount, entryStatus, assets, apiStatus });
} finally { await new Promise(done => server.close(done)); }
}
}
console.table(rows);
Run it with the absolute-base output first:
node check-output.mjs dist-absolute dist-relative
The assertions check that both asset references are present, every entry loads, the nested absolute-base assets fail, the other assets load, and all API probes return 404. The script exits with an error if those expectations change. It still does not execute browser JavaScript or validate a FinClip host.
Top comments (0)