Skip to content

Commit

Permalink
feat: Add CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Aug 16, 2022
1 parent 345f550 commit f837dbe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .env.default
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# 2. `.env` file contents
# 3. `.env.default` file contents.

CORS_ORIGIN=*
CORS_METHODS=*
HTTP_SERVER_PORT=5000
HTTP_SERVER_HOST=0.0.0.0
MARKETPLACE_SUBGRAPH_URL=https://api.thegraph.com/subgraphs/name/decentraland/marketplace
Expand Down
7 changes: 6 additions & 1 deletion src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ export async function initComponents(): Promise<AppComponents> {
const thirtySeconds = 30 * 1000
const fiveMinutes = 5 * 60 * 1000

const cors = {
origin: await config.requireString("CORS_ORIGIN"),
methods: await config.requireString("CORS_METHODS"),
}

const logs = createLogComponent({ config: { logLevel: LOG_LEVEL } })
const server = await createServerComponent<GlobalContext>({ config, logs }, {})
const server = await createServerComponent<GlobalContext>({ config, logs }, { cors })
const statusChecks = await createStatusCheckComponent({ server, config })
const fetch = await createFetchComponent()
const metrics = await createMetricsComponent(metricDeclarations, { server, config })
Expand Down

0 comments on commit f837dbe

Please sign in to comment.