Opt out of Google Chrome tracking everything you do

Add `Permissions-Policy: interest-cohort=()` header to all responses.
This commit is contained in:
Robbie Antenesse 2021-04-15 21:27:57 +00:00
parent 391f2734d8
commit 523e43d26d
1 changed files with 8 additions and 2 deletions

View File

@ -81,7 +81,7 @@ if (!fastify.siteConfig.email_host || !fastify.siteConfig.email_username) {
}
// Every request, check to see if a valid token exists
fastify.addHook('onRequest', async (request, reply) => {
fastify.addHook('onRequest', async (request, reply, done) => {
request.isLoggedInUser = false;
if (typeof request.cookies.token !== 'undefined' && fastify.jwt.verify(request.cookies.token)) {
const { id } = fastify.jwt.verify(request.cookies.token);
@ -101,6 +101,12 @@ fastify.addHook('onRequest', async (request, reply) => {
}
}
request.language = typeof request.cookies.lang !== 'undefined' ? request.cookies.lang : 'en';
// Opt out of Google Chrome tracking everything you do.
// For more info, see: https://plausible.io/blog/google-floc
reply.header('Permissions-Policy', 'interest-cohort=()');
done();
});
// Store i18n files in fastify object and register locales routes
@ -119,4 +125,4 @@ fastify.listen(fastify.siteConfig.port, function (err, address) {
fastify.log.error(err);
process.exit(1);
}
});
});