-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
36 lines (30 loc) · 1.08 KB
/
server.js
File metadata and controls
36 lines (30 loc) · 1.08 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
const express = require('express');
const path = require('path');
const compression = require('compression');
const helmet = require('helmet');
const app = express();
const PORT = process.env.PORT || 3000;
// Middleware de segurança
app.use(helmet({
contentSecurityPolicy: {
directives: {
...helmet.contentSecurityPolicy.getDefaultDirectives(),
"script-src": ["'self'", "'unsafe-inline'", "cdn.tailwindcss.com", "cdnjs.cloudflare.com"],
"style-src": ["'self'", "'unsafe-inline'", "fonts.googleapis.com", "cdnjs.cloudflare.com"],
"img-src": ["'self'", "data:", "api.placeholder.com", "*"],
"font-src": ["'self'", "fonts.gstatic.com", "cdnjs.cloudflare.com"]
}
}
}));
// Compressão GZIP
app.use(compression());
// Servir arquivos estáticos
app.use(express.static(path.join(__dirname, 'public')));
// Rota principal
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'template1.html'));
});
// Iniciar servidor
app.listen(PORT, () => {
console.log(`Servidor rodando na porta ${PORT}`);
});