Commit 76d5589
fix(cors): make origin optional in CORSOptions (#4905)
* fix(cors): make origin optional in CORSOptions
The CORS middleware applies a default of `origin: '*'` when no value is
provided, and the JSDoc already documents `[options.origin='*']` (square
brackets indicating optional). The type required `origin`, so calling
`cors({ allowMethods: ['GET', 'POST'] })` errored at compile time even
though the runtime worked correctly.
Make `origin` optional on `CORSOptions` so the type matches the runtime
default. No runtime change. Test verifies omitting `origin` produces
`Access-Control-Allow-Origin: *` and an explicit `allowMethods` value
still applies.
Closes #4904
* remove the type error
---------
Co-authored-by: Yusuke Wada <yusuke@kamawada.com>1 parent 8f027e5 commit 76d5589
2 files changed
Lines changed: 21 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
421 | 439 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | 69 | | |
73 | | - | |
| 70 | + | |
74 | 71 | | |
75 | 72 | | |
76 | 73 | | |
| |||
0 commit comments