This commit is contained in:
moongladestorm 2025-03-19 13:41:54 +08:00 committed by GitHub
commit c43e8c5bd1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -497,7 +497,8 @@ async function start(opts) {
if (data) { if (data) {
data['server_version'] = data['server_version'] =
`${packageJson.name} v${packageJson.version}`; `${packageJson.name} v${packageJson.version}`;
data['public_url'] = opts.publicUrl || '/'; let xForwardedPath = req.get('X-Forwarded-Path') ? '/' + req.get('X-Forwarded-Path') : '';
data['public_url'] = opts.publicUrl || xForwardedPath + '/';
data['is_light'] = isLight; data['is_light'] = isLight;
data['key_query_part'] = req.query.key data['key_query_part'] = req.query.key
? `key=${encodeURIComponent(req.query.key)}&` ? `key=${encodeURIComponent(req.query.key)}&`
@ -679,11 +680,12 @@ async function start(opts) {
if (opts.publicUrl) { if (opts.publicUrl) {
baseUrl = opts.publicUrl; baseUrl = opts.publicUrl;
} else { } else {
let xForwardedPath = req.get('X-Forwarded-Path') ? '/' + req.get('X-Forwarded-Path') : '';
baseUrl = `${ baseUrl = `${
req.get('X-Forwarded-Protocol') req.get('X-Forwarded-Protocol')
? req.get('X-Forwarded-Protocol') ? req.get('X-Forwarded-Protocol')
: req.protocol : req.protocol
}://${req.get('host')}/`; }://${req.get('host')}${xForwardedPath}/`;
} }
return { return {