-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
52 lines (43 loc) · 1.49 KB
/
server.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
45
46
47
48
49
50
51
52
const https = require('https');
const fs = require('fs');
const path = require('path');
const express = require('express');
const app = express();
// Create a self-signed certificate for localhost
const options = {
key: fs.readFileSync('./localhost-key.pem'),
cert: fs.readFileSync('./localhost.pem'),
};
// Load the .env file
require('dotenv').config();
app.use(express.static('public', {
setHeaders: function (res, path, stat) {
// Set the origin trial token
res.set('Origin-Trial', process.env.TOKEN);
res.set('X-Allow-FLEDGE', 'true');
res.set('Sec-Fetch-Dest', 'fencedframe');
res.set('Supports-Loading-Mode', 'fenced-frame');
}
}));
app.get('/', (_, res) => {
res.sendFile(path.join(__dirname + '/static/html/index.html'));
});
app.get('/advertiser2', (_, res) => {
res.sendFile(path.join(__dirname + '/static/html/advertiser2.html'));
});
app.get('/leave', (_, res) => {
res.sendFile(path.join(__dirname + '/static/html/leave_ig.html'));
});
app.get('/publisher', (_, res) => {
res.sendFile(path.join(__dirname + '/static/html/publisher.html'));
});
app.use('/static', express.static('static', {
setHeaders: function (res, path, stat) {
// Set the origin trial token
res.set('Origin-Trial', process.env.TOKEN);
res.set('X-Allow-FLEDGE', 'true');
res.set('Sec-Fetch-Dest', 'fencedframe');
res.set('Supports-Loading-Mode', 'fenced-frame');
}
}));
https.createServer(options, app).listen(8080);