Configuration, plugins and environment
Register a hook
src/server/plugins.ts with this file. The hook adds a header to every request handled by Fastify.
import type { FastifyInstance } from 'fastify';
export async function configureServer(app: FastifyInstance): Promise<void> {
app.addHook('onRequest', async (_request, reply) => {
reply.header('x-app-name', process.env['APP_NAME'] ?? 'my-fastang-app');
});
}app.register() for Fastify 5 compatible plugins. Install additional plugins in your project: they are not included automatically.
Server variables
PORT=4000 HOST=127.0.0.1 APP_NAME=my-app npm run dev.env files into the Fastify process. PORT must be valid; the default port is 3278 and the default host is 127.0.0.1.
VITE_ variables are intended for the client and can enter the browser bundle. Do not use them for server secrets. Read server variables from process.env in APIs and plugins.
The two configuration files
fastang.config.ts contains explicit prerender URLs and Vercel adapter options. vite.config.ts uses defineFastangConfig() from @fastang/core/vite: this includes Angular compilation, route generation and the server/client boundary.
src/server code, .server.ts files or server runtime APIs into browser components. The bundle check rejects these imports even through another module. Shared types should live in modules that do not load server dependencies.