-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
26 lines (21 loc) · 864 Bytes
/
Copy pathserver.js
File metadata and controls
26 lines (21 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const express = require('express')
const app = express()
const cors = require('cors')
const bodyParser = require('body-parser')
const http = require('http')
const { dbConnect } = require('./utils/db')
const server = http.createServer(app)
require('dotenv').config()
// const CORSBASE = process.env.BASE_URL
// console.log('CORSBASE:', process.env.BASE_URL);
app.use(cors({
origin : ['https://nitiknow.onrender.com','http://localhost:5173'] , //http://localhost:5173, idk if this is good tho process.env.BASE_URL
methods : "GET,HEAD,PUT,PATCH,POST,DELETE",
credentials : true
}))
app.use(bodyParser.json())
app.use('/api', require('./routes/geoRoutes'))
app.get('/',(req,res)=>res.send('My backend'))
const port = process.env.PORT
dbConnect();
server.listen(port, ()=> console.log(`server is running on PORT ${port}`))