Blog
Fastify @fastify/cors: register order, hooks, and encapsulation with plugins
CORS should register early in the plugin graph; child contexts may inherit or override depending on encapsulation.
1 min read
fastifynodejscors
Performance
Fastify’s schema validation runs after CORS; avoid heavy work in onRequest hooks for OPTIONS.
Consider using fastify-plugin to break encapsulation when sharing CORS config across routes.
TypeScript
Augment typings with FastifyCorsOptions when you add custom delegate functions.
Snapshot tests for OPTIONS responses help catch regressions in CI.
