-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
31 lines (28 loc) · 786 Bytes
/
config.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
const rateLimit = require('express-rate-limit');
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // за 15 минут
max: 100, // можно совершить максимум 100 запросов с одного IP
});
const whitelist = [
'http://localhost:3000',
'https://localhost:3000',
'http://localhost:3001',
'https://localhost:3001',
'https://movies-explorer.students.nomoredomains.monster',
'http://movies-explorer.students.nomoredomains.monster',
];
const corsOptions = {
origin(origin, callback) {
if (whitelist.indexOf(origin) !== -1) {
callback(null, true);
} else {
callback(new Error('Not allowed by CORS'));
}
},
credentials: true,
optionsSuccessStatus: 200,
};
module.exports = {
limiter,
corsOptions,
};