Skip to content

Commit e47bae4

Browse files
committed
Use cors defaults when cors: true is set in bedrock config.
1 parent 9880e4b commit e47bae4

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# bedrock-express ChangeLog
22

3+
## 8.5.2 - 2025-12-dd
4+
5+
### Fixed
6+
- Use `cors()` defaults when cors options are specified as `true` in the
7+
bedrock configuration instead of as an object with granular options. It is
8+
important that the defaults are used in this case and not just the "origin"
9+
reflection mechanism both for security reasons and because some newer
10+
browsers do not send an `origin` header in some circumstances.
11+
312
## 8.5.1 - 2025-10-31
413

514
### Fixed

lib/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,10 @@ bedrock.events.on('bedrock.start', async () => {
218218
let corsHandler = null;
219219
if('cors' in cfg) {
220220
if(typeof cfg.cors === 'boolean') {
221-
// if boolean format and pass through
222-
corsHandler = cors({origin: cfg.cors});
221+
// if boolean format use defaults; using "*" is more secure than
222+
// reflecting an origin (see CORS rules) and is what is expected; to
223+
// reflect "origin" back, use an object with "{origin: true, ...}"
224+
corsHandler = cors();
223225
} else {
224226
// if object, use as cors config
225227
corsHandler = cors(cfg.cors);

0 commit comments

Comments
 (0)