The localhost plugin serves a directory over a
http://localhost:<port> origin via tjs.serve (a fetch-style handler)
— for apps that prefer an http origin over the ztron:// asset scheme
(upstream tauri-plugin-localhost parity; internal gap list E1). File
access is gated by a PathScope anchored at the served directory; /
falls back to index.html; content types cover common web assets (with
an application/octet-stream fallback), responses carry the CORS *
header, and misses return 404. The API side exposes three methods,
start(port?) / stop() / status(), all resolving a
LocalhostStatus ({ already?, running?, port, origin?, stopped? }).
Permissions: localhost:allow-start, localhost:allow-stop,
localhost:allow-status, collected in the localhost:default set.
The scope is declared at plugin construction:
localhostPlugin({ dir?, port?, scope? }) — dir is the served
directory (default: cwd), the PathScope anchors on it (default: allow
dir/** plus dir itself) and accepts extra scope entries; /..
traversals are rejected. The hello example does not register this plugin;
from examples/menuprobe/src/main.ts, registration looks like:
The hello frontend does not use this module; the first snippet below is
minimal API-signature usage, the second is from
examples/menuprobe/src/main.ts (the anchor LOCALHOST_OK:<port> is its
real run output; comments kept, excerpts elided):
plugin:localhost|* totals 3 commands:
| Command | API |
|---|---|
start |
start(port?) (returns { already: true, ... } when already running) |
stop |
stop() |
status |
status() |
Full list in the Commands Reference and the API symbol reference.
Applicable version: ztron 0.3.1