-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
44 lines (35 loc) · 1.11 KB
/
app.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const express = require('express');
const bodyParser = require('body-parser');
const session = require('express-session');
const cookieParser = require('cookie-parser');
const authRoutes = require('./routes/authRoutes'); // Ajusta las rutas según tu estructura
const searchRoutes = require('./routes/searchRoutes'); // Ajusta las rutas según tu estructura
require('dotenv').config()
const app = express();
const port = process.env.PORT || 3000;
app.use(bodyParser.json());
app.use(cookieParser());
app.use(
session({
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: true,
cookie: { secure: false }
})
);
const cors=require("cors");
const corsOptions ={
origin:'*',
credentials:true, //access-control-allow-credentials:true
optionSuccessStatus:200,
}
app.use(cors(corsOptions)) // Use this after the variable declaration
app.use('/auth', authRoutes);
app.use('/search', searchRoutes);
app.get('/', (req, res) => {
res.send('Welcome to Spotify Auth App!');
});
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});
module.exports = app;