mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 15:33:12 +09:00
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:
1 parent
0f1fbb8fe5
commit
7c0d7faa24
9 files changed
+81
-7
No files matched your search
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in new issue
Block a user