Merge #826: a password-protected Codeman can be installed as an app

The manifest link fetches manifest.json with the session cookie (crossorigin=use-credentials), so the browser no longer gets a 401 for it.
This commit is contained in:
Codeman maintainer committed 2026-11-20 03:59:10 +01:00
commit b732cec36d
2 files changed
+20 -1

No files matched your search

+2 -1
View File
@@ -13,7 +13,8 @@
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<link rel="apple-touch-icon" href="icon-192.png">
<link rel="manifest" href="manifest.json">
<!-- use-credentials: the manifest fetch otherwise omits the session cookie, so a password-protected install answers 401 and the browser refuses to install the app. -->
<link rel="manifest" href="manifest.json" crossorigin="use-credentials">
<title>Codeman</title>
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0%25' y1='0%25' x2='100%25' y2='100%25'%3E%3Cstop offset='0%25' stop-color='%2360a5fa'/%3E%3Cstop offset='100%25' stop-color='%233b82f6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='32' height='32' rx='6' fill='%230a0a0a'/%3E%3Cpath d='M18 4L8 18h6l-2 10 10-14h-6z' fill='url(%23g)'/%3E%3C/svg%3E">
<link rel="stylesheet" href="styles.css">
+18
View File
@@ -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(/<link\b[^>]*rel="manifest"[^>]*>/g) ?? [];
expect(links).toHaveLength(1);
expect(links[0]).toContain('crossorigin="use-credentials"');
});
});