From 2775f209dc40b9768b23e52518b9fd81220cd667 Mon Sep 17 00:00:00 2001 From: Jakub Szymsza Date: Wed, 4 Sep 2024 11:53:40 +0200 Subject: [PATCH] feat: allow different base path for fastboot --- addon/authenticators/mu-semtech.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/addon/authenticators/mu-semtech.js b/addon/authenticators/mu-semtech.js index ca2705e..19a81b8 100644 --- a/addon/authenticators/mu-semtech.js +++ b/addon/authenticators/mu-semtech.js @@ -7,6 +7,10 @@ export default class MuSemtechAuthenticator extends Base { super(...arguments); const config = getOwner(this).resolveRegistration('config:environment'); this.basePath = config['basePath'] || '/sessions'; + + if (this.isFastboot() && config['fastbootBasePath']) { + this.basePath = config['fastbootBasePath']; + } } async authenticate(options) { @@ -71,12 +75,20 @@ export default class MuSemtechAuthenticator extends Base { } enrichHeadersOnFastboot(headers) { - // note we don't inject the service because we also support apps without fastboot - const fastboot = getOwner(this).lookup('service:fastboot'); - if (fastboot && fastboot.isFastBoot) { - const fastbootHeaders = fastboot.request.headers; + if (this.isFastboot()) { + const fastbootHeaders = this.getFastboot().request.headers; // note that this only works on fastboot, cookie is a forbidden header in the browser headers.append('Cookie', fastbootHeaders.get('Cookie')); } } + + isFastboot() { + const fastboot = this.getFastboot(); + return fastboot && fastboot.isFastBoot; + } + + getFastboot() { + // note we don't inject the service because we also support apps without fastboot + return getOwner(this).lookup('service:fastboot'); + } }