From 41ad45f7f6cb247ee2bcf45c71c6be359ece006d Mon Sep 17 00:00:00 2001 From: S M Mahmudul Hasan Date: Sat, 28 Jun 2025 01:55:53 +0600 Subject: [PATCH 1/2] docs: update pre-flight cors example according to v5 --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 527a0f3..9d59e9e 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,13 @@ app.listen(80, function () { You can also enable pre-flight across-the-board like so: ```javascript -app.options('*', cors()) // include before other routes +// Catch every non-root path +app.options('/*splat', cors()); + +// —or— + +// Catch everything, including '/' +app.options('/{*splat}', cors()); ``` NOTE: When using this middleware as an application level middleware (for From db8e530f45cb0f018757b30f8c523095412662bf Mon Sep 17 00:00:00 2001 From: S M Mahmudul Hasan Date: Sat, 28 Jun 2025 02:23:24 +0600 Subject: [PATCH 2/2] docs: keep express v4 example along with v5 --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 9d59e9e..0b161e1 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,12 @@ app.listen(80, function () { You can also enable pre-flight across-the-board like so: +For express v4, +```javascript +app.options('*', cors()) // include before other routes +``` + +For express v5, ```javascript // Catch every non-root path app.options('/*splat', cors());