From 91d8e5d18e346e83676eab7e4da1c6aff96fff8c Mon Sep 17 00:00:00 2001 From: Melvin Carvalho Date: Mon, 29 Dec 2025 14:20:41 +0100 Subject: [PATCH] fix(getPod): support path-based pod servers The getPod() function previously assumed subdomain-based pods by using document.location.origin. This broke path-based pod servers like JSS and CSS in path mode. Now getPod() first checks if a user is logged in and looks up their pim:storage from their profile. Falls back to origin-based detection for backwards compatibility with subdomain-based servers. Fixes: https://github.com/SolidOS/solid-ui/issues/651 --- src/utils/headerFooterHelpers.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/utils/headerFooterHelpers.ts b/src/utils/headerFooterHelpers.ts index 779cb481..243b0c7d 100644 --- a/src/utils/headerFooterHelpers.ts +++ b/src/utils/headerFooterHelpers.ts @@ -2,6 +2,7 @@ Copied from mashlib/src/global/metadata.ts */ import { IndexedFormula, LiveStore, NamedNode, parse, sym } from 'rdflib' +import { authn, store } from 'solid-logic' import { ns } from '..' /* @ts-ignore no-console */ @@ -15,7 +16,16 @@ type ThrottleOptions = { * @ignore exporting this only for the unit test */ export function getPod (): NamedNode { - // @@ TODO: This is given that mashlib runs on NSS - might need to change when we want it to run on other Pod servers + // Try to get pod from logged-in user's pim:storage + const user = authn.currentUser() + if (user) { + // Look up pim:storage from user's profile + const storages = store.each(user, ns.space('storage'), null, user.doc()) + if (storages.length > 0) { + return storages[0] as NamedNode + } + } + // Fallback to origin-based (subdomain pattern) for backwards compatibility return sym(document.location.origin).site() } /**