Merge pull request 'adding hardcoded meta for onion' (#25) from master into 98

Reviewed-on: #25
This commit is contained in:
Kibi Kelburton
2026-07-26 21:05:20 +00:00
2 changed files with 12 additions and 0 deletions

View File

@@ -331,6 +331,15 @@ function buildGatePage(req) {
'<title>502: Bad Gateway</title>',
`<title>${reqHost} | 502: Bad gateway</title>`
);
// Inject Onion-Location meta tag into <head> 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('<head>', `<head>\n<meta http-equiv="onion-location" content="${onionUrl}">`);
}
html = html.replace('</body>', gateLoginInjection + '\n</body>');
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,