Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Comment on lines +157 to +159
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```javascript
app.options('*cors', cors()) // include before other routes; the cors string after the * is arbitrary
```
```javascript
app.options('*cors', cors()) // For Express v4, just use '*' for the route.


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.
Expand Down