mirror of
https://github.com/wassname/talk.git
synced 2026-07-13 17:45:56 +08:00
[CORL-529] Proxy (#2473)
* fix: implemented trust configuration * fix: removed debugging code * fix: increase hash size (#2484)
This commit is contained in:
@@ -223,10 +223,10 @@ export default function createWebpackConfig(
|
||||
// Generated JS file names (with nested folders).
|
||||
// There will be one main bundle, and one file per asynchronous chunk.
|
||||
filename: isProduction
|
||||
? "assets/js/[name].[chunkhash:8].js"
|
||||
? "assets/js/[name].[chunkhash].js"
|
||||
: "assets/js/[name].js",
|
||||
chunkFilename: isProduction
|
||||
? "assets/js/[name].[chunkhash:8].chunk.js"
|
||||
? "assets/js/[name].[chunkhash].chunk.js"
|
||||
: "assets/js/[name].chunk.js",
|
||||
// We inferred the "public path" (such as / or /my-project) from homepage.
|
||||
publicPath,
|
||||
@@ -357,7 +357,7 @@ export default function createWebpackConfig(
|
||||
options: {
|
||||
limit: 10000,
|
||||
name: isProduction
|
||||
? "assets/media/[name].[hash:8].[ext]"
|
||||
? "assets/media/[name].[hash].[ext]"
|
||||
: "assets/media/[name].[ext]",
|
||||
},
|
||||
},
|
||||
@@ -370,7 +370,7 @@ export default function createWebpackConfig(
|
||||
options: {
|
||||
modules: true,
|
||||
importLoaders: 2,
|
||||
localIdentName: "[name]-[local]-[hash:base64:5]",
|
||||
localIdentName: "[name]-[local]-[contenthash]",
|
||||
sourceMap: !disableSourcemaps,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import compileTrust from "./compileTrust";
|
||||
|
||||
it("parses boolean true", () => {
|
||||
expect(compileTrust("true")).toStrictEqual(true);
|
||||
});
|
||||
|
||||
it("parses boolean false", () => {
|
||||
expect(compileTrust("false")).toStrictEqual(false);
|
||||
});
|
||||
|
||||
it("parses a number", () => {
|
||||
for (let i = 0; i < 100; i++) {
|
||||
expect(compileTrust(`${i}`)).toStrictEqual(i);
|
||||
}
|
||||
});
|
||||
|
||||
it("parses a list of aliases", () => {
|
||||
const aliases = "loopback, linklocal, uniquelocal";
|
||||
expect(compileTrust(aliases)).toStrictEqual(aliases);
|
||||
});
|
||||
|
||||
it("parses an of address", () => {
|
||||
const address = "10.0.0.1";
|
||||
expect(compileTrust(address)).toStrictEqual(address);
|
||||
});
|
||||
|
||||
it("parses a list of addresses", () => {
|
||||
const addresses = "10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, fc00::/7";
|
||||
expect(compileTrust(addresses)).toStrictEqual(addresses);
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
function compileTrust(trust: string) {
|
||||
if (!trust) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const lowercase = trust.toLowerCase();
|
||||
if (lowercase === "true" || lowercase === "false") {
|
||||
return lowercase === "true";
|
||||
}
|
||||
|
||||
const parsed = Number(trust);
|
||||
if (!isNaN(parsed)) {
|
||||
return parsed;
|
||||
}
|
||||
|
||||
return trust;
|
||||
}
|
||||
|
||||
export default compileTrust;
|
||||
@@ -0,0 +1,5 @@
|
||||
export { default as compileTrust } from "./compileTrust";
|
||||
export { default as Entrypoints } from "./entrypoints";
|
||||
|
||||
export * from "./hostname";
|
||||
export * from "./entrypoints";
|
||||
@@ -22,6 +22,7 @@ import { PersistedQueryCache } from "coral-server/services/queries";
|
||||
import { AugmentedRedis } from "coral-server/services/redis";
|
||||
import TenantCache from "coral-server/services/tenant/cache";
|
||||
|
||||
import { compileTrust } from "./helpers";
|
||||
import { accessLogger, errorLogger } from "./middleware/logging";
|
||||
import { metricsRecorder } from "./middleware/metrics";
|
||||
import serveStatic from "./middleware/serveStatic";
|
||||
@@ -111,7 +112,7 @@ function configureApplication(options: AppOptions) {
|
||||
// SSL was terminated correctly.
|
||||
const trust = options.config.get("trust_proxy");
|
||||
if (trust) {
|
||||
parent.set("trust proxy", trust);
|
||||
parent.set("trust proxy", compileTrust(trust));
|
||||
}
|
||||
|
||||
// Setup the view config.
|
||||
|
||||
Reference in New Issue
Block a user