Skip to content

Commit

Permalink
feat: Allow regex CORS origins
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Apr 15, 2024
1 parent ebdcfc8 commit ec6fa86
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .env.default
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
HTTP_SERVER_PORT=3000
HTTP_SERVER_HOST=0.0.0.0

CORS_ORIGIN=*
CORS_ORIGIN=^http:\/\/localhost:[0-9]{1,10}$
CORS_METHODS=*

# reset metrics at 00:00UTC
Expand Down
3 changes: 2 additions & 1 deletion src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ export async function initComponents(): Promise<AppComponents> {

let databaseUrl: string | undefined = await config.getString('PG_COMPONENT_PSQL_CONNECTION_STRING')
const COLLECTIONS_SUBGRAPH_URL = await config.requireString('COLLECTIONS_SUBGRAPH_URL')

const cors = {
origin: await config.requireString('CORS_ORIGIN'),
origin: (await config.requireString('CORS_ORIGIN')).split(';').map(origin => new RegExp(origin)),
methods: await config.requireString('CORS_METHODS')
}

Expand Down

0 comments on commit ec6fa86

Please sign in to comment.