Skip to content

Commit

Permalink
allow cors
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmtimbo committed Apr 30, 2023
1 parent 3bdd5b4 commit db8c780
Show file tree
Hide file tree
Showing 3 changed files with 931 additions and 832 deletions.
2 changes: 2 additions & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@google-cloud/firestore": "^4.12.0",
"axios": "^0.21.1",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"express-async-errors": "^3.1.1",
Expand All @@ -26,6 +27,7 @@
"devDependencies": {
"@types/cookie-parser": "^1.4.2",
"@types/express": "^4.17.12",
"@types/cors": "^2.8.13",
"npm-run-all": "^4.1.5",
"ts-node-dev": "^1.1.6",
"typescript": "^4.3.2"
Expand Down
9 changes: 9 additions & 0 deletions server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@ require('dotenv').config()
import express, { NextFunction, Request, Response } from 'express'
import 'express-async-errors'
import cookieParser from 'cookie-parser'
import cors from 'cors'

const app = express()
app.use(cookieParser())

// must be after the call to expressWs above
import * as handlers from './handlers'

const corsOptions = {
origin: '*',
credentials: true,
optionsSuccessStatus: 200,
}

app.use(cors(corsOptions))

app.use('/api', handlers.api)
app.use('/', handlers.files)

Expand Down
Loading

0 comments on commit db8c780

Please sign in to comment.