Add config to set URL for static assets

Add option in the controller config to set where static assets are
loaded from in order to support deployments where the static assets are
server via a CDN while the API is directly accessed.

This is useful because some CDNs put low limits on how large requests
bodies can be, which causes issues with uploading large mods and saves.
This commit is contained in:
Hornwitser committed 2026-08-31 19:17:31 +02:00
1 parent 0f1fbb8fe5
commit 7c0d7faa24
9 files changed
+81 -7

No files matched your search

+28
View File
@@ -184,7 +184,35 @@ describe("lib/config/validators", function() {
describe("lib/config/definitions/validators", function() {
describe("Controller Config", function() {
it("should validate controller.static_url", function() {
const config = new ControllerConfig("controller");
// valid cases
config.set("controller.static_url", "");
config.set("controller.static_url", null);
config.set("controller.static_url", "static/");
config.set("controller.static_url", "./static/");
config.set("controller.static_url", "/static/");
config.set("controller.static_url", "http://example/static/");
// invalid cases
assert.throws(
() => config.set("controller.static_url", "/foo/"),
"Path component of static_url must be \/static\/ not \/foo\/."
);
assert.throws(
() => config.set("controller.static_url", "http://example/foo/static/"),
"Path component of static_url must be \/static\/ not \/foo\/static\/."
);
assert.throws(
() => config.set("controller.static_url", "http://example/static"),
"Path component of static_url must be \/static\/ not \/static."
);
assert.throws(
() => config.set("controller.static_url", "http://:80"),
/Invalid URL/,
);
});
});
describe("Host Config", function() {
+7 -1
View File
@@ -43,7 +43,13 @@ describe("lib/plugin_loader", function() {
it("should load test plugin", async function() {
assert.deepEqual(
await lib.loadPluginInfos(new Map([["test", path.resolve(testPlugin)]])),
[{ name: "test", version: "0.0.1", npmPackage: undefined, requirePath: path.resolve(testPlugin) }]
[{
name: "test",
version: "0.0.1",
npmPackage: undefined,
requirePath: path.resolve(testPlugin),
webStaticPath: path.resolve(path.join(testPlugin, "dist", "web", "static")),
}]
);
});
it("should reject on broken plugin", async function() {