CSS and JavaScript per route
Meerkat rewrites the HTML of the UI routes it proxies, to add the little of itself the visitor needs - and to add whatever you write on the route.
Only HTML answers are touched, and only on UI routes. An API route's JSON is never rewritten.
What the gateway already injects
| What | Where it lands | When |
|---|---|---|
| The tracing bundle | top of <body>, first of all |
when the route is traced (its OpenTelemetry section) |
The page agent, /meerkat/page.js |
top of <body> |
on every UI route |
| The user button, or the portal bar | top of <body>, with the agent |
depending on the route and the portal |
| The scheme override for the application's own storage | top of <body>, just before the agent |
when the route declares one (Light and dark) |
| Your CSS and JavaScript blocks | where each block says: start of the head, end of the head, or end of the body | when the route carries some |
| The language hook | after <head> |
when the route's language mechanism is a script |
| The maintenance stripe | after <head> |
only for an administrator who chose to go through while the gateway is in maintenance, to check an application before reopening it |
The agent carries the visitor's language, their light or dark choice, and the session watch. No route opts out of it: a page with no agent is a page that goes on looking signed in for hours after the session ended.
The agent and the button are one injection, in that order, and deliberately: both scripts are deferred, so they run in document order, and the button's element must not upgrade before the agent has defined what it reads. Two separate insertions would each land right after <body> and put the second one first.
The agent and the button go at the top of the body, never inside the head. A custom element inside <head> closes it where it stands, and everything after it - charset, title, and <base href> - lands in the body, where a base is ignored. An application served under a prefix would then resolve every URL from the root.
Your own CSS and JavaScript
Add a block
- Open Infra, Routes, open the route, and make sure its UI box is ticked.
- Open the Custom section. Under Injections, click Add and choose CSS, written here, CSS file, JavaScript, written here or JavaScript file.
- Write the code (Write it), or upload the file.
- Choose Where: Start of the head, End of the head or End of the body. For JavaScript, choose how it Runs (below).
- Click Save.
- Check: open the application through the gateway, View source, and find your block at its place. A file is linked from the gateway's own path.
On a UI route, the Custom section holds an ordered list of blocks. Each is CSS or JavaScript, written there or uploaded as a file, and placed at the start of the head, at its end, or at the end of the body; the list is the order within each place. Written CSS rides a <style> tag, written JavaScript a <script> tag, both verbatim; a file is linked from the gateway's own path.

Each block has a toggle on its line. Off, the block stays on the route - its code or its file kept - and leaves the page, and its file is no longer served; on again, it is back where it was. That is the way to rule a block out while finding what breaks a page, without deleting anything.
A JavaScript block also says how it Runs. A stylesheet has no such setting.
| Runs | Written as | Allowed on |
|---|---|---|
| In place | a classic <script>, run where it stands |
written code and files |
| Deferred | defer: run once the document is parsed, in order |
files only: a browser ignores it on written code |
| Async | async: run as soon as it is loaded, in no set order |
files only |
| Module | type="module" |
written code and files |
| Rule | Why |
|---|---|
At most 64 KiB each |
plenty for page tweaks; more is a bundle, and a bundle belongs to the application |
</style and </script are refused on save |
either would break out of the tag it travels in |
Placed at the start of the head, a block comes before the application's own stylesheets and scripts, and the application's rules win on equal specificity. Placed at the end of the head, a stylesheet comes after them and overrides them: that is where an override belongs, rather than reaching for !important.
Styling on the visitor's roles
The session's effective roles can be stamped onto the served HTML, server-side. No client JavaScript, no call home. Your CSS can then hide or show elements by role with nothing but a selector.
It is set in the route's User info section: tick Inject the user's roles, and choose As:
| As | Default name | Result for a person holding BILLING and OPS |
|---|---|---|
| classes on a tag | tag body |
<body class="BILLING OPS"> |
| an attribute on a tag | data-roles on body |
<body data-roles="BILLING OPS"> |
| a meta tag | meerkat-roles |
<meta name="meerkat-roles" content="BILLING OPS"> |
With roles as classes on body, this hides the refund button from whoever does not hold BILLING_ADMIN:
body:not(.BILLING_ADMIN) .refund { display: none; }
The same section stamps the user's own facts, with Inject the user info, as attributes on a tag or meta tags: username, userid, fullname, email, tenant, tenantid, timezone, currency and locale, plus the custom fields your installation declares. Each is written under a name you choose, by default the field itself: tenantid="acme". A fact the person does not have is left out: no time zone chosen on the profile, no time zone attribute, and the page uses the browser's.
A CSS rule that hides an element is a convenience, not a protection: whoever opens the page can show it again. What a person may do is decided by the route's security and by the application.
no-store, and the headers that could say otherwise - Expires, Pragma, Last-Modified, ETag - are removed, whatever the application behind says. Without that, a public, max-age=300 - the default of every static file server - would have a CDN, a corporate proxy or a shared browser serve Alice's page to Bob.An anonymous request is not stamped and keeps the application's own caching.
The cost
Rewriting a body means holding it in memory. The ceiling is Infra, Routes, Global, Body rewriting ceiling: between one and two hundred and fifty-six MiB, and twenty by default. Past it the answer is forwarded intact and whole: nothing breaks, the injection simply does not apply. The cost is per request being served at that moment, so a large ceiling multiplies by however many arrive together.
The role stamping is gated on a cheap session check, so anonymous requests never buffer anything.
What is missing
- Rewriting
<base href>to match a stripped prefix: nothing rewrites it, which is why the injection is careful never to close the head. - A post-authentication hook and presets for common tools: the JavaScript block is there, the hook that would run at sign-in is not.
- Rewriting OpenAPI specs in proxied answers: only the developer documentation portal rewrites the spec it serves.