add server settings api

This commit is contained in:
Nystik
2026-06-06 13:04:34 +02:00
parent 938a698795
commit b43d12f702
6 changed files with 141 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
const express = require("express");
const dns = require("dns").promises;
const net = require("net");
const settings = require("../settings");
const router = express.Router();
@@ -105,6 +106,19 @@ router.post("/", async (req, res) => {
return res.status(e.statusCode || 400).json({ error: e.message });
}
// When a host allowlist is defined , the proxy only reaches those hosts.
const allowlist = settings.get("proxyAllowlist");
if (allowlist.length > 0) {
const host = new URL(url).hostname;
if (!allowlist.includes(host)) {
return res
.status(403)
.json({ error: `Host not in proxy allowlist: ${host}` });
}
}
try {
// Forward the caller's headers as-is.
const fetchOpts = {