Skip to content

Commit

Permalink
cors added for vercel
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamc4t committed Feb 15, 2024
1 parent 97f0f38 commit 61c94ac
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ dotenv.config()
const app: Express = express()
const port = process.env.PORT || 3005

const allowedOrigins = ['http://localhost:3000', 'https://dnd-shop-generator.vercel.app']
const corsOptions = {
origin: allowedOrigins,
}

app.use(cors(corsOptions))
app.use(express.json())

app.get('/', (req: Request, res: Response) => {
Expand All @@ -19,12 +25,6 @@ app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`)
})

const corsOptions = {
origin: 'http://localhost:3000',
}

app.use(cors(corsOptions))

mongoose
.connect(
'mongodb+srv://dndAdmin:[email protected]/dnd-db?retryWrites=true&w=majority',
Expand Down

0 comments on commit 61c94ac

Please sign in to comment.