Blog

@fastify/cors plugin: preflight hooks, dynamic origin functions, and route-level OPTIONS overrides

Fastify lets you compute Allow-Origin per request—cache expensive database lookups carefully to avoid slowing OPTIONS.

1 min read
fastifycorsnodejs

Plugins ecosystem

Order matters: register CORS before routes that attach schemas, or validation may reject OPTIONS bodies.

Multipart plugins can change Content-Type expectations—mirror Allow-Headers for file uploads.

HTTP/2 and HTTP/3

Server push is rarely used with CORS-heavy SPAs—disable push for API subdomains to simplify caches.

QUIC connection migration should not change perceived origin for credentialed requests.

Back to blog