feat(web): icons and the web manifest are public for browsers and app installers

This commit is contained in:
2026-10-23 21:51:49 +01:00
parent 8527506da1
commit a5f7cdf302
3 changed files with 48 additions and 4 deletions
+5
View File
@@ -51,6 +51,8 @@ async function staticFile(base, pathname, req, res) {
} catch { reply(res, 404, 'Not found'); }
}
const PUBLIC_ASSET = /^\/(favicon\.(svg|png|ico)|apple-touch-icon\.png|manifest\.json|icons\/[A-Za-z0-9-]+\.png)$/;
function upstreamRequest(target, options, callback) {
return (target.protocol === 'https:' ? httpsRequest : httpRequest)(
{ protocol: target.protocol, hostname: target.hostname, port: target.port || undefined,
@@ -125,6 +127,9 @@ export async function start({ root = resolve('build/web'), upstream = 'http://12
}
if (pathname === '/login' || pathname === '/logout' || pathname === '/chat-uploads' || pathname.startsWith('/artifacts/')) return proxy(req, res, target);
if (req.method !== 'GET' && req.method !== 'HEAD') return reply(res, 405);
// Icons and the web manifest are public: browsers and app installers
// fetch them without the session cookie.
if (PUBLIC_ASSET.test(pathname)) return staticFile(base, pathname, req, res);
authCheck(req, target, (authenticated) => {
if (res.destroyed) return;
if (authenticated === null) return reply(res, 502, 'Authentication upstream unavailable');