forked from fijjas/prerender-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
34 lines (29 loc) · 1.21 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
const prerender = require('prerender');
const forwardHeaders = require('./plugins/forwardHeaders');
const forwardResponseHeaders = require('./plugins/forwardResponseHeaders');
const stripHtml = require('./plugins/stripHtml');
const healthcheck = require('./plugins/healthcheck');
const removePrefetchTags = require('./plugins/removePrefetchTags');
const log = require('./plugins/log');
const consoleDebugger = require('./plugins/consoleDebugger');
const options = {
pageDoneCheckInterval: process.env.PAGE_DONE_CHECK_INTERVAL || 500,
pageLoadTimeout: process.env.PAGE_LOAD_TIMEOUT || 20000,
waitAfterLastRequest: process.env.WAIT_AFTER_LAST_REQUEST || 250,
chromeFlags: [ '--no-sandbox', '--headless', '--disable-gpu', '--remote-debugging-port=9222', '--hide-scrollbars' ],
};
console.log('Starting with options:', options);
const server = prerender(options);
server.use(log);
server.use(healthcheck('_health'));
server.use(forwardHeaders);
server.use(forwardResponseHeaders);
server.use(prerender.blockResources());
server.use(prerender.removeScriptTags());
server.use(removePrefetchTags);
server.use(prerender.httpHeaders());
if (process.env.DEBUG_PAGES) {
server.use(consoleDebugger);
}
server.use(stripHtml);
server.start();