Skip to content

Commit

Permalink
adding CORS configuration to our Express.js server to allow it to ac…
Browse files Browse the repository at this point in the history
…cept requests from 'http://localhost:5173'. (#89)
  • Loading branch information
mayura-andrew authored Jan 11, 2024
1 parent 7f87fbc commit 6260132
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ app.use(cookieParser())
app.use(bodyParser.json())
app.use(cors())
app.use(passport.initialize())

app.use(
cors({
origin: 'http://localhost:5173', // allow to server to accept request from different origin
methods: 'GET, HEAD, PUT, PATCH, DELETE', // allow to perform http methods
credentials: true // allow session cookie from browser to pass through
})
)
app.get('/', (req, res) => {
res.send('ScholarX Backend')
})
Expand Down

0 comments on commit 6260132

Please sign in to comment.