Public endpoints
Let callers outside the dashboard, such as a provider's webhook, reach a backend route through the frontend server without a session or an Origin.
The server proxies a state-changing request with the session only when the request carries an Origin that matches the frontend's own. The request then goes out with the signed-in user's session. A route meant for callers outside the dashboard fails both ways. Examples are a mail provider's delivery webhook and a payment provider's callback. The caller sends no Origin, and the proxy does not relay its secret header.
A backend module declares such a route public when it registers its frontend:
import path from "node:path";
import { AddFrontendModule } from "@antelopejs/interface-dms/page";
await AddFrontendModule({
name: "@antelopejs/dms-mailing-frontend-vue",
sourcePath: path.join(__dirname, "../frontend-vue"),
renderer: { name: "vue", version: "3" },
publicEndpoints: [
{
path: "/api/mailing/events/*/*",
methods: ["POST"],
headers: ["x-mailing-webhook-secret"],
},
],
});
A request to a public endpoint behaves as follows:
- It needs no
Origin. - The proxy never sends it the session, even from a signed-in browser, so a cross-site form that posts to it acts as nobody. The route authenticates its caller itself, with a shared secret or a signature.
- It carries the module's declared headers on top of the usual ones.
Declaration rules
pathis an absolute/api/path. Its first segment is literal, the module's own prefix and never*. Each later*segment matches exactly one segment. Nothing else matches, so there is no prefix match, no query string, and no.or..segment.methodsdefaults to["POST"], and acceptsGET,HEAD,POST,PUT,PATCHandDELETE.headersnames the module's ownx-headers. The server refuses the ones that a proxy or the DMS gives a meaning to:x-forwarded-*,x-real-ip,x-dms-*,x-inertia*, the method overrides (x-http-method*,x-method-override),x-original-*andx-rewrite-*. A name without thex-prefix, such asauthorizationorcookie, is refused too.- The server drops a malformed declaration whole, with a warning, and never widens it.
The proxy matches the request's normalized path, the one it sends to the backend. A .., %2e%2e or \ therefore cannot reach another route through a public one. When a module route answers a public endpoint's path, the server reports it at startup.
DMS_PUBLIC_ENDPOINTS adds entries of the same shape, as a JSON array, for a route that no module declares:
DMS_PUBLIC_ENDPOINTS=[{"path":"/api/acme/hooks/*","methods":["POST"],"headers":["x-acme-signature"]}]