Client - serving content
jetQuery serves the browser UI itself: static files (css, js, images, fonts, html pages) and the index - the single HTML page (SPA shell) that loads the UI.
Files come from system files (the server www folder) and from client applications. The index is built from www/index.html and, for signed-in users, can be replaced by their own application's pages/index.html.
Terms used on this page:
- System files - the server
wwwfolder (internal app nameaaa-server). - Client application - an application with
app_client = true(marked asUI). Its files are served and its components are bundled into the index. Set withPOST /api/core/apps/update/{app_name}(app_administrator), see Apps. - User app context - the application selected by the signed-in user (
user_app_name), set withPOST /api/core/account/context/{app_name}, see Account.
Request lifecycle
Every request goes through the same steps:
- Block list - a request whose path matches
blocked-url.txt(e.g..php,/.env,/wp-admin) adds the client IP toblocked-ip.txtfor 15 minutes; blocked IPs get404for every request. - Tenant - the tenant is resolved from the
Hostheader; an unknown domain is rejected. - Authentication - the user is identified, when present, from the
ptokencookie,Authorization: Bearer|Token|Basic, or?ptoken=api:{token}(which also sets theptokencookie). Content routes are anonymous - authentication only changes which index is returned. - Routing - the path selects one of the handlers below.
| Path | Result |
|---|---|
/api/... |
API endpoint, unknown endpoint → 404 |
/assets/..., /components/..., /js/..., /css/..., /images/..., /p/..., /favicon.ico, /favicon.png |
Static file |
/pages/... |
Page - static file with fallback to the index |
/robots.txt, /sw.js |
file from system files, 404 if missing |
/manifest.json |
manifest.json from the server folder, or a default manifest |
any other path without extension, e.g. /, /srs/124, /login |
Index |
any other path with an extension, e.g. /test.png |
404 (exception: paths containing @, e.g. /recover/{uuid}/{email}) |
Static files
| HTTP | |
|---|---|
Resolution - first match wins:
- Client applications, in alphabetical order of
app_name:{app folder}/css/site.css. - System files:
www/css/site.css. - Not found →
404.
Rules:
- Only these extensions are served, other extensions →
403:.css, .html, .js, .mjs, .cjs, .ts, .mts, .cts, .pdf, .json, .ico, .woff, .woff2, .ttf, .otf, .jpg, .jpeg, .png, .svg, .webp, .gif, .mp4 - The file is served exactly as requested - there is no automatic
.minlookup. Minified versions are used only when the index is built, see Building the index. ?app_name={app_name}looks only in that client application, then in system files;?app_name=aaa-serverreads only from system files. The index uses this for linked components.- A path that resolves outside the application or
wwwfolder, or contains\, →404. - Responses carry an
ETag(last write time + size); a matchingIf-None-Matchreturns304.
Pages
/pages/ works like static files, plus clean URLs and a fallback to the index:
| Request | Tried in order (first match wins) |
|---|---|
/pages/test.html |
pages/test.html → index |
/pages/test |
pages/test.html → pages/test/index.html → index |
/pages/test.js (any other extension) |
pages/test.js → 404 |
Each candidate file is resolved like a static file (client applications, then system files). A trailing slash is ignored: /pages/test/ is the same as /pages/test.
Index
The index is returned for every route of the UI. Which index depends on the user - first match wins:
| User | Index |
|---|---|
| anonymous | server index |
| signed in | pages/index.html of the user app context → server index |
The user app index is used only when all of these are true:
- the user has an app context (
user_app_name), - the user has role
app_{app_name}orapp_administrator, - the request comes from an address allowed by the application
app_locations, - the file
{app folder}/pages/index.htmlexists.
How the user app index is served:
- File contains
content="jetQuery.io"(exact text, case-sensitive, normally in<meta name="generator" content="jetQuery.io" />) → it is a template, built like the server index, see Building the index. - Otherwise → the file is returned as is, no tokens are replaced.
Warning
pages/index.html replaces the whole UI for every user of the application. Anyone with app_{app_name}_write can change it (storage save/upload), so treat this role as able to run JavaScript in the browsers of all users of the application.
Note
A broken user app index cannot be bypassed with a query parameter (?paanda=recovery was removed). Fix the file, change the user app context (POST /api/core/account/context/{app_name}), or delete pages/index.html.
Example
/srs/124has no extension → index.- The user is signed in with app context
erpand has roleapp_erp→{datastore}/apps/erp/pages/index.htmlexists → it containscontent="jetQuery.io"→ the built template is returned. - The same request without the cookie returns the server index.
Building the index
The server index is built from www/index.html. A user app template is built the same way - only the HTML shell differs.
-
Collect components from system files and from every client application:
Folder Type Priority /js/.js10 /components/.js20 /pages/.js33 /css/.css100 Subfolders are included. Only
.jsand.cssfiles are bundled -.htmlfiles are never bundled. -
Remove duplicates - one component per file name (e.g.
v_home.js), the first one in this order wins: 1. lower priority number, 2. relative path, alphabetically (/components/system/v_home.jsbefore/components/v_home.js), 3. for the same relative path - application name in reverse alphabetical order, so a client application overrides a system file with the same path. - Validate - a
.jsfile outside/js/must have a valid JavaScript function name (0-9a-zA-Z_), otherwise it is skipped and a warning is written to the browser console. - Minify or link:
-
name.min.js/name.min.cssnext toname.js/name.css→ the.minfile is used as is, - file smaller thanjetquery_server_bundle_size(default150000bytes) → minified and inlined in the page, - larger file → linked:<script src="{host}/components/v_big.js?t={modified}&app_name={app}">. - Place -
.jswith!bodyin the path →@paanda_body, other.js→@paanda_head,.css→@css_init. - Replace tokens in the template:
Token Value @css_initcss components @paanda_headjs components (place in <head>)@paanda_body!bodyjs components (place at the end of<body>)@paanda_warningsconsole warnings, empty if none @variables.settings.system.versionserver version @template_time,@template_datebuild time in ms, build date (UTC) @time_tokentime of the last application settings change ( apps/update)@apiurl,@hosting_domain{scheme}://{host}of the request, e.g.https://app.example.com
Minimal template, e.g. {app folder}/pages/index.html:
Note
Avoid the same file path in two client applications. Static files take the first application in alphabetical order, the index build takes the last one.
Caching and refresh
The built index is kept in server memory per tenant and per scheme (http / https), so a request only returns the cached page.
The index (server index and all user app templates) is rebuilt on the next request after:
POST /api/core/apps/create|update|scm-pull|scm-reset/{app_name}POST /api/core/storage/upload|save|delete|scm-checkout/{app_name}/...- server restart
A user app template is also rebuilt when the file pages/index.html changes (last write time or size).
Warning
Files changed directly on disk (copy, git pull outside the API) are not picked up until one of the calls above or a restart. Static files are always read from disk.
If the build fails, e.g. the database is not reachable, the page shows the error and is not cached - the next request tries again.
HTTP caching:
- Index:
ETag+Cache-Control: private, no-cache- the browser revalidates every time (304when unchanged); the same URL returns different content for different users, so shared caches (proxy, CDN) must not store it. - Static files:
ETagonly.
Local development
POST /api/core/dev/client-index builds the index with local component files instead of the server ones, see DevOPS Automation.
Application directory structure
example:
/components- components, bundled into the index (.js)/pages- pages:.jsbundled into the index,.htmlserved on/pages/...,pages/index.html- optional user app index/js- javascript, bundled into the index/css- client css, bundled into the index/srs- api definition files, not served as files/templates- templates (svg, mail), not served as files
Folders /components, /pages, /js, /css are used only when the application is a client application (app_client = true), except pages/index.html, which is used for the user app context.