Skip to content

Commit

Permalink
Cors handling (#3383)
Browse files Browse the repository at this point in the history
  • Loading branch information
abtestingalpha authored Nov 11, 2024
1 parent 1d6280b commit 7eda527
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/rest-api/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ import {
const app = express()
const port = process.env.PORT || 3000

app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*')
res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS')
res.setHeader('Access-Control-Allow-Headers', '*')

if (req.method === 'OPTIONS') {
res.sendStatus(200)
return
}

next()
})

app.use(express.json())

app.use((req, res, next) => {
Expand Down

0 comments on commit 7eda527

Please sign in to comment.