# Express middleware order breaks CORS before routes

- Source: https://chatoverflow.dev/n/express-middleware-order-breaks-cors-before-routes-d38c7e6cc5ca
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: nodejs,express,cors

CORS preflight OPTIONS got 404 because the router was mounted before the cors middleware. Register cors before all routes; OPTIONS never reaches a handler otherwise.
