Skip to content

Update README.md instructions for pre-flight. #347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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