From a07c21f22ba9b07ebaedad0fcb6da195aac2dda1 Mon Sep 17 00:00:00 2001 From: Kibi Kelburton Date: Sun, 26 Jul 2026 23:04:45 +0200 Subject: [PATCH] adding hardcoded meta for onion --- src/index.mjs | 11 +++++++++++ views/snippets/header.html | 1 + 2 files changed, 12 insertions(+) diff --git a/src/index.mjs b/src/index.mjs index 970015e..b9e024d 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -331,6 +331,15 @@ function buildGatePage(req) { '502: Bad Gateway', `${reqHost} | 502: Bad gateway` ); + // Inject Onion-Location meta tag into for Tor Browser compatibility + if (cfg.websrv?.enable_tor_hs !== false && cfg.main?.onion && req && req.headers && !req.headers['host']?.endsWith('.onion')) { + const p = req.url?.pathname || '/'; + const s = req.url?.search || ''; + const onionHost = cfg.main.onion.replace(/\/+$/, ''); + const onionUrl = `${onionHost}${p}${s}`; + html = html.replace('', `\n`); + } + html = html.replace('', gateLoginInjection + '\n'); return html; } @@ -1325,6 +1334,8 @@ process.on('uncaughtException', err => { show_mime_picker: cfg.websrv.show_mime_picker !== false, private_society: cfg.websrv.private_society || false, private_society_gate: cfg.websrv.private_society_gate || '', + onion: cfg.main.onion || '', + enable_tor_hs: cfg.websrv.enable_tor_hs !== false, show_content_warning: cfg.websrv.show_content_warning !== false, web_url_upload: !!cfg.websrv.web_url_upload, enable_youtube_upload: cfg.websrv.enable_youtube_upload !== false, diff --git a/views/snippets/header.html b/views/snippets/header.html index 227cc98..bb2e3e7 100644 --- a/views/snippets/header.html +++ b/views/snippets/header.html @@ -2,6 +2,7 @@ + @if(enable_tor_hs && onion)@endif @if(typeof page_meta !== 'undefined' && page_meta.title){{ domain }} - {{ page_meta.title }}@elseif(typeof item !== 'undefined'){{ domain }} - {{ item.id }}@else{{ domain }}@endif -- 2.50.1