1.0.0 • Published 3 years ago

dont-give-a-floc v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

dont-give-a-floc

Disable FLoC on your hapi server

Build Status Coverage Status

Installation

npm install dont-give-a-floc

Usage

This module is a hapi plugin to control whether FLoC is allowed on pages served by your hapi server, using the Permissions-Policy header. You may disable FLoC to protect your users' privacy, preventing access to their cohorts via browser APIs (including in third-party scripts on your page), and opting your site out of FLoC calculations which are based on user browsing history.

Simply register the plugin to your server, optionally passing the disableFloc plugin option if you'd like it to take effect across all routes. Otherwise, you can disable FLoC on individual routes using the route.options.plugins.disableFloc option.

Example

const Hapi = require('@hapi/hapi');
const DontGiveAFloc = require('dont-give-a-floc');

(async () => {

    const server = Hapi.server();

    await server.register(DontGiveAFloc);

    server.route({
        method: 'get',
        path: '/',
        options: {
            plugins: {
                disableFloc: true
            },
            handler(request, h) {

                return h.response(`<html>
                    <head><title>My FLoC-less Homepage</title></head>
                    <body>No FLoCs given!</body>
                </html>`).type('text/html');
            }
        }
    });
})();

Extras

1.0.0

3 years ago