Skip to Content
HeronJS v4 is now available.
Versionv4SecurityHelmet & CORS

Security Headers & CORS

Configure framework CORS and default security headers through HttpOptions from @heronjs/common.

import type {HttpOptions} from '@heronjs/common'; export const httpOptions: HttpOptions = { cors: {origin: 'https://example.test', methods: ['GET', 'POST']}, securityHeaders: true, trustProxy: false, bodyLimit: 1024 * 1024, }; // await app.listen({port: 3000, options: httpOptions});

Use cors: false to disable CORS registration. Custom Helmet policies, sessions and native plugins belong in options.setup, using a disposable http() lease. Top-level helmet, session and fastify options are rejected in 4.7.0. Install any native plugin you register and complete registration before readiness.

MCP and ACP enforce their own Host/Origin allowlists; HTTP CORS does not replace those checks. See HTTP configuration.

Last updated on