diff --git a/CHANGELOG.md b/CHANGELOG.md index 06614f4..025710e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # bedrock-kms-http ChangeLog +## 23.0.0 - 2025-10-dd + +### Changed +- **BREAKING**: `helpers.getKeystoreId` will use `config.server.baseUri` + rather than `req.host` to align with other Bedrock service behavior. + ## 22.1.0 - 2025-09-28 ### Changed diff --git a/lib/helpers.js b/lib/helpers.js index ea0b45b..a5f1512 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -1,14 +1,13 @@ /*! - * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved. + * Copyright (c) 2019-2025 Digital Bazaar, Inc. All rights reserved. */ +import * as bedrock from '@bedrock/core'; import forwarded from 'forwarded'; import ipaddr from 'ipaddr.js'; -export function getKeystoreId({host, req, localId, routes}) { - if(!host) { - host = req.get('host'); - } - return `https://${host}${routes.keystores}/${localId}`; +export function getKeystoreId({localId, routes}) { + const {baseUri} = bedrock.config.server; + return `${baseUri}${routes.keystores}/${localId}`; } export function verifyRequestIp({keystoreConfig, req}) { diff --git a/lib/http.js b/lib/http.js index 9a84343..deafeed 100644 --- a/lib/http.js +++ b/lib/http.js @@ -110,7 +110,7 @@ bedrock.events.on('bedrock-express.configure.routes', app => { // create a keystore for the controller const random = await generateRandom(); - const id = helpers.getKeystoreId({req, localId: random, routes}); + const id = helpers.getKeystoreId({localId: random, routes}); const config = {id, meterId, ...req.body}; const record = await keystores.insert({config}); res.status(201).location(id).json(record.config); diff --git a/lib/middleware.js b/lib/middleware.js index 52ee181..5a62747 100644 --- a/lib/middleware.js +++ b/lib/middleware.js @@ -32,7 +32,7 @@ export function createGetKeystoreConfig({routes}) { return asyncHandler(async function _getKeystoreConfig(req, res, next) { if(!req.webkms) { const keystoreId = helpers.getKeystoreId( - {req, localId: req.params.keystoreId, routes}); + {localId: req.params.keystoreId, routes}); const configRecord = await storage.get({ id: keystoreId, req, returnRecord: true });