From bc288581465643ef556314d203faccdbffad2f64 Mon Sep 17 00:00:00 2001 From: reya Date: Tue, 23 Jan 2024 14:31:49 +0700 Subject: [PATCH] pass url prefix to handlebar --- src/daemon/run.ts | 8 +++++--- templates/createAccount.handlebar | 2 +- templates/login.handlebar | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/daemon/run.ts b/src/daemon/run.ts index 813a700..ea672f1 100644 --- a/src/daemon/run.ts +++ b/src/daemon/run.ts @@ -174,13 +174,15 @@ class Daemon { async startWebAuth() { if (!this.config.authPort) return; - const prefix = new URL(this.config.baseUrl as string).pathname.replace(/\/+$/, ''); + const urlPrefix = new URL(this.config.baseUrl as string).pathname.replace(/\/+$/, ''); this.fastify.register(FastifyView, { engine: { - handlebars: Handlebars + handlebars: Handlebars, }, - prefix + defaultContext: { + urlPrefix + } }); this.fastify.listen({ port: this.config.authPort }); diff --git a/templates/createAccount.handlebar b/templates/createAccount.handlebar index 34bd312..8af35b3 100644 --- a/templates/createAccount.handlebar +++ b/templates/createAccount.handlebar @@ -87,7 +87,7 @@
{{#if error}} diff --git a/templates/login.handlebar b/templates/login.handlebar index 5f97a4b..c10c3d6 100644 --- a/templates/login.handlebar +++ b/templates/login.handlebar @@ -52,7 +52,7 @@