new(all): SSR enabled for test in PROD.

This commit is contained in:
Rodrigo Rodriguez 2022-02-20 18:49:32 -03:00
parent b5d99c3fa4
commit 02898ad898
3 changed files with 28 additions and 15 deletions

View file

@ -142,9 +142,9 @@ export class GBMinService {
// SSR processing.
const defaultOptions = {
prerender: [],
exclude: ["/api/", "/instances/", "/webhooks/"],
useCache: true,
prerender: [],
exclude: ["/api/", "/instances/", "/webhooks/"],
useCache: true,
cacheRefreshRate: 86400
};
GBServer.globals.server.use(ssrForBots(defaultOptions));
@ -156,6 +156,17 @@ export class GBMinService {
// default.gbui access definition.
GBServer.globals.server.use('/', express.static(url));
GBServer.globals.server.use('/ssr-delay', async (req,res) => {
const sleep = async ms => {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
await sleep(10000);
res.status(200);
res.end();
});
}
// Servers the bot information object via HTTP so clients can get
@ -336,9 +347,9 @@ export class GBMinService {
if (botId === '[default]' || botId === undefined) {
botId = GBConfigService.get('BOT_ID');
}
GBLog.info(`Client requested instance for: ${botId}.`);
// Processes group behaviour.

View file

@ -38,6 +38,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="shortcut icon" href="%PUBLIC_URL%/ssrdelay">
<link rel="stylesheet" type="text/css" href="./css/pragmatismo.css" />
<script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
<title>General Bots Community Edition | pragmatismo.io</title>

View file

@ -212,19 +212,19 @@ export class GBServer {
};
if (process.env.CERTIFICATE_PFX) {
var options = {
passphrase: process.env.CERTIFICATE_PASSPHRASE ,
passphrase: process.env.CERTIFICATE_PASSPHRASE,
pfx: fs.readFileSync(process.env.CERTIFICATE_PFX)
};
};
const httpsServer = https.createServer(options, server).listen(port, mainCallback);
const httpsServer = https.createServer(options, server).listen(port, mainCallback);
if (process.env.CERTIFICATE2_PFX) {
var options = {
passphrase: process.env.CERTIFICATE2_PASSPHRASE ,
pfx: fs.readFileSync(process.env.CERTIFICATE2_PFX)
};
httpsServer.addContext(process.env.CERTIFICATE2_DOMAIN, options);
if (process.env.CERTIFICATE2_PFX) {
var options = {
passphrase: process.env.CERTIFICATE2_PASSPHRASE,
pfx: fs.readFileSync(process.env.CERTIFICATE2_PFX)
};
httpsServer.addContext(process.env.CERTIFICATE2_DOMAIN, options);
}
}
else {
server.listen(port, mainCallback);