Server configuration
A full-stack Brix application has three server-facing files. src/brix.ts holds browser-safe contracts and configuration. src/brix.server.ts calls defineBrixServer(brix, options) to attach server-only concerns: environment, authentication, caching, security policy, middleware, logging, and integrations. src/app.ts calls createBrixApp(brixServer) to assemble the Hono application that the generated production entry serves with your discovered routes.
Managed React applications are browser-only and have no Brix server; see application types.
Recommended path
#- Assemble the server and confirm a discovered route runs through the production app.
- Add authentication and security policy if any route is private, accepts mutations, or is called from another origin. Applications that sign in through brix-auth use its framework-owned policy.
- Add middleware, errors, and observability after the request boundary works.
- Choose a deployment target only after local route tests and
brix verifypass.
What happens on every request
#createBrixApp installs infrastructure in a fixed order. Application options plug into specific steps; they cannot be reordered:
- Request ID. A valid incoming
x-request-idis reused, otherwise Brix generates one, and it is returned on the response. - Environment. When
envis configured, the platform's environment snapshot is parsed. A failure returns a sanitized 500 and skips everything below except security headers. - Logging and timing. The request logger,
c.timings, and therequest.startrecord begin. - Security headers and CSP. Default secure headers and a fresh CSP nonce are applied to every response; Markdown and plain-text responses get a script-free policy without the nonce.
- Cross-origin mutation guard. Cross-origin browser
POST,PUT,PATCH, andDELETErequests receive 403. - Built-in assets. Production builds serve generated assets and
public/files before any route. - Locale, then translations.
resolveLocaleand the translation loader run. - Application middleware. Your
middlewarearray runs in order. - Routes. Integration and OpenAPI routes, then discovered routes. Each route applies its own body limit, authentication, and route middleware before the handler or loader.
Responses also carry X-App-Version when a release version is known; see application version.