diff --git a/aidlc-docs/features/andreaslop-site-hosting/audit.md b/aidlc-docs/features/andreaslop-site-hosting/audit.md
index 805f1cc..c510ab1 100644
--- a/aidlc-docs/features/andreaslop-site-hosting/audit.md
+++ b/aidlc-docs/features/andreaslop-site-hosting/audit.md
@@ -464,3 +464,9 @@
## Redeploy after the admin-files fix
**Timestamp**: 2026-11-08
**Run**: 610 (dispatch, deploy_asf_test only), head d0c1d26, all gates and deploy-asf-test green. Live checks: /admin/ , /admin/index.html, /admin/favicon-theme.png (image/png), hashed css (text/css, contains the ASF palette) and js (text/javascript) all 200; /admin/dashboard 200 SPA; /admin/assets/missing.js and /api/v1/unknown 404 with empty body; /assets/missing.js 404 with the website 404 page; /health version 1.0.0+d0c1d26.
+
+## Defect on the live ASF test host: invitation link pointed at the website root
+**Timestamp**: 2026-11-08
+**Found by**: Bryan; analysed with CMS & API.
+**Root cause**: the API returns an app-relative path (`/invite/complete?token=...`); the frontend built the shown/copied URL as `origin + inviteLink` in InviteUserDialog (2x) and UsersPage, ignoring the router basepath (`/admin/` in builds). On ASF the root is the prerendered website, so the link hit its 404 page; SlpSoftware only worked through its root SPA fallback.
+**Fix** (frontend only; API contract and shared Identity unchanged, SlpSoftware unaffected, already-issued links keep working there): `lib/links.ts buildAppUrl = origin + BASE_URL (no trailing slash) + path`, used in the 3 places. Tests: helper (prod/dev base, trailing slashes, missing leading slash, no double slash, encoded token), dialog link value. Frontend 304 tests green.
diff --git a/frontend/src/features/invitation/components/InviteUserDialog.test.tsx b/frontend/src/features/invitation/components/InviteUserDialog.test.tsx
index f59bf99..865d686 100644
--- a/frontend/src/features/invitation/components/InviteUserDialog.test.tsx
+++ b/frontend/src/features/invitation/components/InviteUserDialog.test.tsx
@@ -53,7 +53,13 @@ describe('InviteUserDialog', () => {
await userEvent.click(screen.getByTestId('invite-dialog-submit'));
- expect(await screen.findByTestId('invite-dialog-link-input')).toBeInTheDocument();
+ const linkInput = await screen.findByTestId('invite-dialog-link-input');
+ expect(linkInput).toBeInTheDocument();
+ // origin + app base + the path from the API (base is '/' under test, '/admin/' in a build).
+ expect((linkInput as HTMLInputElement).value).toBe(
+ `${window.location.origin}${import.meta.env.BASE_URL.replace(/\/+$/, '')}/invite/complete?token=${(linkInput as HTMLInputElement).value.split('token=')[1]}`,
+ );
+ expect((linkInput as HTMLInputElement).value).toContain('/invite/complete?token=');
expect(screen.getByTestId('invite-dialog-copy')).toBeInTheDocument();
});
diff --git a/frontend/src/features/invitation/components/InviteUserDialog.tsx b/frontend/src/features/invitation/components/InviteUserDialog.tsx
index 69724ad..636f130 100644
--- a/frontend/src/features/invitation/components/InviteUserDialog.tsx
+++ b/frontend/src/features/invitation/components/InviteUserDialog.tsx
@@ -1,4 +1,5 @@
import { useState } from 'react';
+import { buildAppUrl } from '@/lib/links';
import { useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { toast } from 'sonner';
@@ -79,7 +80,7 @@ export function InviteUserDialog({ open, onOpenChange }: InviteUserDialogProps)
const handleCopy = async () => {
if (!inviteLink) return;
- await navigator.clipboard.writeText(`${window.location.origin}${inviteLink}`);
+ await navigator.clipboard.writeText(buildAppUrl(inviteLink));
toast.success(t('users.actions.linkCopied'));
};
@@ -163,7 +164,7 @@ export function InviteUserDialog({ open, onOpenChange }: InviteUserDialogProps)
diff --git a/frontend/src/features/users/pages/UsersPage.tsx b/frontend/src/features/users/pages/UsersPage.tsx
index bf43094..65d1ae4 100644
--- a/frontend/src/features/users/pages/UsersPage.tsx
+++ b/frontend/src/features/users/pages/UsersPage.tsx
@@ -1,4 +1,5 @@
import { useState } from 'react';
+import { buildAppUrl } from '@/lib/links';
import { toast } from 'sonner';
import { useTranslation } from 'react-i18next';
import { MoreHorizontal, Link as LinkIcon, Trash2, UserX, UserCheck } from 'lucide-react';
@@ -102,7 +103,7 @@ export function UsersPage() {
const handleCopyInviteLink = async (user: UserListItem) => {
if (!user.inviteLink) return;
- await navigator.clipboard.writeText(`${window.location.origin}${user.inviteLink}`);
+ await navigator.clipboard.writeText(buildAppUrl(user.inviteLink));
toast.success(t('users.actions.linkCopied'));
};
diff --git a/frontend/src/lib/links.test.ts b/frontend/src/lib/links.test.ts
new file mode 100644
index 0000000..76a9d41
--- /dev/null
+++ b/frontend/src/lib/links.test.ts
@@ -0,0 +1,51 @@
+import { describe, expect, it } from 'vitest';
+import { buildAppUrl } from '@/lib/links';
+
+const ORIGIN = 'https://test.andreaslop.nl';
+
+describe('buildAppUrl', () => {
+ it('puts the admin base path between origin and path (production build)', () => {
+ expect(buildAppUrl('/invite/complete?token=abc', '/admin/', ORIGIN)).toBe(
+ 'https://test.andreaslop.nl/admin/invite/complete?token=abc',
+ );
+ });
+
+ it('works without a trailing slash on the base', () => {
+ expect(buildAppUrl('/invite/complete?token=abc', '/admin', ORIGIN)).toBe(
+ 'https://test.andreaslop.nl/admin/invite/complete?token=abc',
+ );
+ });
+
+ it('adds nothing for the root base (dev server)', () => {
+ expect(buildAppUrl('/invite/complete?token=abc', '/', 'http://localhost:5173')).toBe(
+ 'http://localhost:5173/invite/complete?token=abc',
+ );
+ });
+
+ it('tolerates a path without a leading slash', () => {
+ expect(buildAppUrl('invite/complete', '/admin/', ORIGIN)).toBe('https://test.andreaslop.nl/admin/invite/complete');
+ });
+
+ it('keeps an encoded token intact', () => {
+ expect(buildAppUrl('/invite/complete?token=a%2Fb%3D', '/admin/', ORIGIN)).toBe(
+ 'https://test.andreaslop.nl/admin/invite/complete?token=a%2Fb%3D',
+ );
+ });
+
+ it.each([
+ ['/admin/', '/invite/complete?token=a'],
+ ['/admin//', '/invite/complete?token=a'],
+ ['/admin', 'invite/complete?token=a'],
+ ['/', '/invite/complete?token=a'],
+ ['', 'invite/complete?token=a'],
+ ])('never produces a double or missing slash (base %j, path %j)', (base, path) => {
+ const url = buildAppUrl(path, base, ORIGIN);
+
+ expect(url.replace('https://', '')).not.toContain('//');
+ expect(url).toMatch(/^https:\/\/test\.andreaslop\.nl(\/admin)?\/invite\/complete\?token=a$/);
+ });
+
+ it('defaults to the Vite base and the current origin', () => {
+ expect(buildAppUrl('/x')).toBe(`${window.location.origin}${import.meta.env.BASE_URL.replace(/\/+$/, '')}/x`);
+ });
+});
diff --git a/frontend/src/lib/links.ts b/frontend/src/lib/links.ts
new file mode 100644
index 0000000..8d3d2af
--- /dev/null
+++ b/frontend/src/lib/links.ts
@@ -0,0 +1,18 @@
+/**
+ * Turns an app-relative path from the API (for example an invitation link,
+ * `/invite/complete?token=...`) into an absolute URL a person can open.
+ *
+ * The admin is mounted under a base path ('/admin/' in builds, '/' in dev), which is the same value the
+ * router uses as its basepath. Prefixing only the origin would point at the host root, which on a host
+ * that serves a separate website there is that website's page, not this app.
+ */
+export function buildAppUrl(
+ appPath: string,
+ base: string = import.meta.env.BASE_URL,
+ origin: string = window.location.origin,
+): string {
+ const trimmedBase = base.replace(/\/+$/, '');
+ const path = appPath.startsWith('/') ? appPath : `/${appPath}`;
+
+ return `${origin}${trimmedBase}${path}`;
+}