GuidesFile Handling
Static Files
Available from
v1.7.0-beta
Arkos automatically serves files from a public/ folder in your project root. Any file placed there is accessible directly by its path — no route configuration required.
GET /public/logo.svg
GET /favicon.icoStatic files are not prefixed with globalPrefix. A file at public/logo.svg is served at /logo.svg, not /api/logo.svg.
How it works
On startup, Arkos checks for the configured static folder. If it doesn't exist, it creates it and emits a warning. To disable static file serving entirely, set staticFiles.enabled = false in your config.
Configuration
All fields are optional and deep-merged with defaults.
| Key | Type | Description | Default |
|---|---|---|---|
enabled | boolean | Whether to enable static file serving | true |
folder | string | Folder to serve, relative to project root | "public" |
prefix | string | URL prefix under which files are served | "/" |
expressStatic | object | Options passed to express.static() — deep-merged with defaults | See below |
expressStatic defaults:
{
maxAge: "1y",
etag: true,
lastModified: true,
dotfiles: "ignore",
fallthrough: true,
index: false,
cacheControl: true,
}import { defineConfig } from "arkos";
export default defineConfig({
staticFiles: {
folder: "assets",
prefix: "/static",
expressStatic: {
maxAge: "7d",
},
},
});Opting out
import { defineConfig } from "arkos";
export default defineConfig({
staticFiles: {
enabled: false,
},
});Related
- File Upload Setup — handling user-uploaded files