Skip to content

Commit

Permalink
use firs item from origins array (#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablomendezroyo authored Nov 8, 2024
1 parent 4c4d60d commit 699ab85
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
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
2 changes: 1 addition & 1 deletion packages/brain/src/modules/apiServers/ui/startUiServer.ts
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

0 comments on commit 699ab85

Please sign in to comment.