From 346be954feec15524b3a5d041b07772703d143d9 Mon Sep 17 00:00:00 2001 From: Jan Van Buggenhout Date: Fri, 9 May 2025 09:54:34 -0700 Subject: [PATCH] Update README.md instructions for pre-flight. --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 37ab8cf..2d6b98b 100644 --- a/README.md +++ b/README.md @@ -154,10 +154,19 @@ app.listen(80, function () { You can also enable pre-flight across-the-board like so: +```javascript +app.options('*cors', cors()) // include before other routes; the cors string after the * is arbitrary +``` + +NOTE: previous versions of this documentation suggested the following: + ```javascript app.options('*', cors()) // include before other routes ``` +Since path-to-regexp broke API and requires wildcards to be named, this no +longer works in Express 5. + NOTE: When using this middleware as an application level middleware (for example, `app.use(cors())`), pre-flight requests are already handled for all routes.