mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-02 04:52:50 +08:00
fix(web): make bot-link usable on public IP with HTTP
The "复制专属链接" button silently failed on public-IP HTTP deployments because navigator.clipboard requires a secure context. Now the link is always revealed in a modal with a read-only input (select-all on focus), so users can copy manually even when clipboard APIs and execCommand both fail. The dialog still tries to auto-copy when possible. Also adds a publicUrl config option that overrides window.location.origin for link generation (useful behind reverse proxies / with custom domains), exposed via GET /api/config/public-url, and a trustProxy flag so Express honors X-Forwarded-* when fronted by nginx/Caddy/Cloudflare. https://claude.ai/code/session_019FSX3S3UUcKEYWanYmoqUv
This commit is contained in:
4 files changed
+206
-26
No files matched your search
@@ -38,8 +38,18 @@ export function createWebServer(options: WebServerOptions): WebServer {
|
||||
const server = http.createServer(app);
|
||||
const logger = options.logger.child({ component: "web" });
|
||||
|
||||
if (options.config.trustProxy) {
|
||||
// Honor X-Forwarded-* from a reverse proxy (nginx/Caddy/Cloudflare).
|
||||
app.set("trust proxy", true);
|
||||
}
|
||||
|
||||
app.use(express.json());
|
||||
|
||||
app.get("/api/config/public-url", (_req, res) => {
|
||||
const raw = (options.config.publicUrl ?? "").trim();
|
||||
res.json({ publicUrl: raw ? raw.replace(/\/+$/, "") : null });
|
||||
});
|
||||
|
||||
app.use(
|
||||
"/api/bot",
|
||||
createBotRouter(options.botManager, options.config, options.configPath, logger)
|
||||
|
||||
Reference in new issue
Block a user