-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
50 lines (36 loc) · 1.11 KB
/
index.js
File metadata and controls
50 lines (36 loc) · 1.11 KB
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
45
46
47
48
49
50
const express = require('express');
const connectDB = require('./config/db');
const cors = require('cors');
//Crea el server
const app = express();
//Conectar a la bd
connectDB();
//Habilitar cors
app.use(cors());
//Habilitar express.json
app.use( express.json({ extended : true }));
//Puerto de la app
const port = process.env.PORT || 5000;
//Importar rutas
app.use('/api/users', require('./routes/users'));
app.use('/api/auth', require('./routes/auth'));
app.use('/api/forms', require('./routes/forms'));
// app.use('/api/recommender', require('./routes/recommender'));
//
app.get('/', (req, res)=> {
res.send('FinnMx')
})
app.use((req, res, next) => {
// If no routes match, send them the React HTML.
res.sendFile(__dirname + "/public/index.html");
});
app.use(cors({
credentials: true,
origin: ['https://competent-agnesi-9c644c.netlify.app'] // <== this will be the URL of our React app (it will be running on port 3000)
// origin: ['http://localhost:3000']
}));
//Arrancar la app
app.listen(port, '0.0.0.0', () => {
// app.listen(PORT, () => {
console.log(`Server listening on port ${port}`)
});