From 2a8722865433cbbec26f1411d03f7facff8e62cf Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Sun, 2 Feb 2025 22:28:00 +0100 Subject: [PATCH] Hooks: Update pocketbase URL --- src/hooks.server.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/hooks.server.ts b/src/hooks.server.ts index a3c5689..848ad97 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -15,10 +15,14 @@ export const handle: Handle = async ({ event, resolve }) => { // Otherwise use the default local development IP:Port. // Because we imported "$env/dynamic/private", // the variables will only be available to the server (e.g. .server.ts files). - const pb_url = - env.PB_HOST && env.PB_PORT - ? `http://${env.PB_HOST}:${env.PB_PORT}` - : "http://192.168.86.50:8090"; + let pb_url: string = "http://192.168.86.50:8090"; + if (env.PB_PROTOCOL && env.PB_HOST && env.PB_PORT) { + pb_url = `${env.PB_PROTOCOL}://${env.PB_HOST}:${env.PB_PORT}`; + } + if (env.PB_PROTOCOL && env.PB_URL) { + pb_url = `${env.PB_PROTOCOL}://${env.PB_URL}`; + } + event.locals.pb = new PocketBase(pb_url); // Load the most recent authentication data from a cookie (is updated below)