Skip to content

Commit 76bcdaa

Browse files
committed
Use baseUri.
1 parent 01effac commit 76bcdaa

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
## 22.2.0 - 2025-10-dd
44

55
### Changed
6-
- `helpers.getKeystoreId` will use `config.server.host` first if defined
7-
before falling back to `req.host` to improve reliability when operating
8-
behind a reverse proxy.
6+
- `helpers.getKeystoreId` will use `config.server.host` rather than
7+
`req.host` to align with other Bedrock service behavior.
98

109
## 22.1.0 - 2025-09-28
1110

lib/helpers.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ import ipaddr from 'ipaddr.js';
77

88
const {config} = bedrock;
99

10-
export function getKeystoreId({host, req, localId, routes}) {
11-
if(!host) {
12-
host = config.server.host || req.get('host');
13-
}
14-
return `https://${host}${routes.keystores}/${localId}`;
10+
export function getKeystoreId({localId, routes}) {
11+
const {baseUri} = config.server;
12+
return `${baseUri}${routes.keystores}/${localId}`;
1513
}
1614

1715
export function verifyRequestIp({keystoreConfig, req}) {

lib/http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ bedrock.events.on('bedrock-express.configure.routes', app => {
110110

111111
// create a keystore for the controller
112112
const random = await generateRandom();
113-
const id = helpers.getKeystoreId({req, localId: random, routes});
113+
const id = helpers.getKeystoreId({localId: random, routes});
114114
const config = {id, meterId, ...req.body};
115115
const record = await keystores.insert({config});
116116
res.status(201).location(id).json(record.config);

lib/middleware.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function createGetKeystoreConfig({routes}) {
3232
return asyncHandler(async function _getKeystoreConfig(req, res, next) {
3333
if(!req.webkms) {
3434
const keystoreId = helpers.getKeystoreId(
35-
{req, localId: req.params.keystoreId, routes});
35+
{localId: req.params.keystoreId, routes});
3636
const configRecord = await storage.get({
3737
id: keystoreId, req, returnRecord: true
3838
});

0 commit comments

Comments
 (0)