Serve application from local server
For better context, learn more about the following JS APIs:
Tizen CoreApp (v2.12.x and above) includes a local HTTP server running on http://localhost:10081/ that can serve files from the device's internal storage.
This is a specialty feature designed for a use case of serving third-party SPAs that use absolute paths (e.g., /assets/app.js,
/content/page.html) which cannot be loaded directly from the filesystem.
Most offline content can be handled with
sos.offline.cache or sos.fileSystem — those APIs cache files and return local file paths that work directly
in <img>, <video>, or <iframe> tags. You only need the local server when a third-party web application uses absolute-path
references that must resolve against a real HTTP origin.
The local server is only accessible from the device itself (localhost). Other devices on the same network cannot reach it.
File storage and URL mapping
To make files available on the local server, save them under the data/localServer path prefix using sos.fileSystem. The directory
structure maps directly to the URL path:
Saved to sos.fileSystem path | Accessible at |
|---|---|
data/localServer/index.html | http://localhost:10081/index.html |
data/localServer/assets/styles.css | http://localhost:10081/assets/styles.css |
data/localServer/assets/bundle.js | http://localhost:10081/assets/bundle.js |
Because the HTML uses absolute-path references (e.g., /assets/styles.css), the browser resolves them against localhost:10081 and loads
everything from disk — no URL rewriting is needed.
The data/localServer prefix is required for sos.fileSystem to place files in the correct directory. Do not change this prefix.
Supported file types
The local server automatically sets the correct Content-Type header based on the file extension:
| Extension | Content-Type |
|---|---|
.html | text/html; charset=utf-8 |
.json | application/json; charset=utf-8 |
.js | application/javascript; charset=utf-8 |
.css | text/css; charset=utf-8 |
.svg | image/svg+xml |
.png | image/png |
.jpg, .jpeg | image/jpeg |
.mp4 | video/mpeg |
.webp | image/webp |
.woff2 | font/woff2 |
.woff | font/woff |
Workflow
A typical pattern for deploying a third-party SPA offline:
Because all assets are served from the device's internal storage, the application continues to work even when the device loses its internet connection.