Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
Merge c6a3cd9 into e27c871
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Oct 15, 2019
2 parents e27c871 + c6a3cd9 commit 76e3696
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app.json
@@ -1,6 +1,11 @@
{
"name": "srihash",
"scripts": {},
"env": {},
"env": {
"SRIHASH_FORCE_SSL": {
"description": "Force SSL redirection",
"value": "true"
}
},
"addons": []
}
8 changes: 7 additions & 1 deletion index.js
Expand Up @@ -10,6 +10,7 @@ const vision = require('@hapi/vision');
const inert = require('@hapi/inert');
const handlebarsHelperSRI = require('handlebars-helper-sri');
const handlebarsPartialFile = require('handlebars-partial-file');
const requireHttps = require('hapi-require-https');
const generate = require('./lib/generate');
const generateElement = require('./lib/generateElement');

Expand All @@ -26,6 +27,7 @@ hbsPartialFile.registerDirectory('badge', 'svg');
// eslint-disable-next-line quotes
const CSP_HEADER = "default-src 'none'; base-uri 'none'; form-action 'self'; frame-src 'self'; frame-ancestors 'self'; img-src 'self'; manifest-src 'self'; style-src 'self'";
const REFERRER_HEADER = 'no-referrer, strict-origin-when-cross-origin';
const PLUGINS = [vision, inert];

(async() => {
try {
Expand All @@ -43,7 +45,11 @@ const REFERRER_HEADER = 'no-referrer, strict-origin-when-cross-origin';
}
});

await server.register([vision, inert]);
if (process.env.SRIHASH_FORCE_SSL === 'true') {
PLUGINS.push(requireHttps);
}

await server.register(PLUGINS);

server.views({
engines: {
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -36,6 +36,7 @@
"handlebars": "^4.4.3",
"handlebars-helper-sri": "0.0.0",
"handlebars-partial-file": "^1.0.0",
"hapi-require-https": "^4.0.0",
"node-fetch": "^2.6.0",
"sri-toolbox": "^0.2.0"
},
Expand Down

0 comments on commit 76e3696

Please sign in to comment.