From 14dccd462ffce610e33cca0ad6eb15284848d5a8 Mon Sep 17 00:00:00 2001 From: Kamil Kalisz Date: Mon, 16 Nov 2026 11:51:27 +0100 Subject: [PATCH] fix(pwa): fetch the manifest with credentials so password installs can be installed Browsers fetch the web app manifest without cookies unless the link sets crossorigin="use-credentials". With a password set, manifest.json needs the codeman_session cookie, so it answered 401 and Chrome refused to install Codeman as an app. Co-Authored-By: Claude Opus 5.5 --- src/web/public/index.html | 3 ++- test/pwa-manifest-credentials.test.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/pwa-manifest-credentials.test.ts diff --git a/src/web/public/index.html b/src/web/public/index.html index 7d1d1430..10c20449 100644 --- a/src/web/public/index.html +++ b/src/web/public/index.html @@ -13,7 +13,8 @@ - + + Codeman diff --git a/test/pwa-manifest-credentials.test.ts b/test/pwa-manifest-credentials.test.ts new file mode 100644 index 00000000..a0c332f5 --- /dev/null +++ b/test/pwa-manifest-credentials.test.ts @@ -0,0 +1,18 @@ +/** + * @fileoverview The manifest link must be fetched with credentials. Browsers fetch the web app + * manifest without cookies unless the link says `crossorigin="use-credentials"`, and every + * non-exempt path needs the `codeman_session` cookie when a password is set, so without the + * attribute the manifest answers 401 and the browser refuses to install Codeman as an app. + */ +import { describe, expect, it } from 'vitest'; +import { readFileSync } from 'node:fs'; + +const HTML = readFileSync(new URL('../src/web/public/index.html', import.meta.url), 'utf-8'); + +describe('PWA manifest link', () => { + it('requests the manifest with credentials so a password-protected install can be installed', () => { + const links = HTML.match(/]*rel="manifest"[^>]*>/g) ?? []; + expect(links).toHaveLength(1); + expect(links[0]).toContain('crossorigin="use-credentials"'); + }); +});