Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function startBrainApi({
allowedOriginsFromEnv
}: {
brainDb: BrainDataBase;
allowedOriginsFromEnv: string[] | null;
allowedOriginsFromEnv: string | string[] | null;
}): http.Server {
const app = express();
app.use(express.json());
Expand Down
2 changes: 1 addition & 1 deletion packages/brain/src/modules/apiServers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const getServers = ({
beaconchainApi: BeaconchainApi;
brainDb: BrainDataBase;
reloadValidatorsCronTask: CronJob;
allowedOriginsFromEnv: string[] | null;
allowedOriginsFromEnv: string | string[] | null;
}): {
uiServer: http.Server;
launchpadServer: http.Server;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function startLaunchpadApi({
brainDb: BrainDataBase;
network: Network;
signerUrl: string;
allowedOriginsFromEnv: string[] | null;
allowedOriginsFromEnv: string | string[] | null;
}): http.Server {
const app = express();
app.use(express.json());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function startUiServer({
uiBuildPath: string;
brainConfig: BrainConfig;
reloadValidatorsCronTask: CronJob;
allowedOriginsFromEnv: string[] | null;
allowedOriginsFromEnv: string | string[] | null;
}): http.Server {
const { network } = brainConfig.chain;
// create index.html modified with network
Expand Down
11 changes: 9 additions & 2 deletions packages/brain/src/modules/config/loadEnvs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function loadEnvs(): {
executionClient: ExecutionClient;
consensusClient: ConsensusClient;
isMevBoostSet: boolean;
cors: string[] | null;
cors: string | string[] | null;
} {
const network = getNetwork();

Expand All @@ -14,12 +14,19 @@ export function loadEnvs(): {

const isMevBoostSet = process.env[`_DAPPNODE_GLOBAL_MEVBOOST_${network.toUpperCase()}`] === "true";

const origins = process.env.CORS ? process.env.CORS.split(",") : null;
let cors: string | string[] | null = null;
if (origins) {
if (origins.length > 1) cors = origins;
else if (origins.length === 1) cors = origins[0];
}

return {
network: network as Network,
executionClient,
consensusClient,
isMevBoostSet,
cors: process.env.CORS ? process.env.CORS.split(",") : null
cors
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/brain/src/modules/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface ApisConfig {
token: string;
tlsCert: Buffer | null;
host: string;
cors: string[] | null;
cors: string | string[] | null;
}

export interface ChainConfig {
Expand Down