From 7cf9cfa96e2e4d24d34ad4530641d5a5a60e383a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gast=C3=B3n=20Fournier?= Date: Thu, 16 May 2024 11:45:16 +0200 Subject: [PATCH] fix: bearer tokens with base-path (#7065) ## About the changes We've identified that Bearer token middleware is not working for /enterprise instance. Looking at a few lines below: https://github.com/Unleash/unleash/blob/88e3b1b79efc0954951a4ee270483c1fd2bf97dc/src/lib/app.ts#L81-L84 we can see that we were missing the basePath in the use definition. --- src/lib/app.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/app.ts b/src/lib/app.ts index a49f979296..d2843ee535 100644 --- a/src/lib/app.ts +++ b/src/lib/app.ts @@ -61,7 +61,7 @@ export default async function getApp( app.use(requestLogger(config)); - app.use('/api', bearerTokenMiddleware(config)); // We only need bearer token compatibility on /api paths. + app.use(`${baseUriPath}/api`, bearerTokenMiddleware(config)); // We only need bearer token compatibility on /api paths. if (typeof config.preHook === 'function') { config.preHook(app, config, services, db);