fastify-floc-off
Fastify plugin to opt-out of Google's Topics advertising-surveillance API
Overview
The fastify-floc-off
plugin adds the "interest-cohort=()" directive to the Permissions-Policy
response header to opt-out of Google's Topics advertising-surveillance API. It will create a new header if one does not already exist.
This was originally created to opt-out of Google's FLoC (Federated Learning of Cohorts), which has since been replaced with their Topics API, though it has the same privacy issues.
More information about the issues surrounding Google's FLoC can be found on EFF and Plausible Analytics.
Helmet and fastify-helmet do not support the Permissions-Policy
response header setting yet, so this plugin was created out of a need for an easy way to disable/opt-out of Google's Topics API. This ensures users accessing web applications are not subject to Google's unsolicited tracking.
Installation
Install using npm
:
npm i fastify-floc-off
Compatibility
Plugin version | Fastify version |
---|---|
>=3.x |
^5.x |
>=2.x <3.x |
^4.x |
>=1.x <2.x |
^3.x |
Please note that if a Fastify version is out of support, then so are the corresponding versions of this plugin in the table above. See Fastify's LTS policy for more details.
Example usage
const Fastify = require("fastify");
const flocOff = require("fastify-floc-off");
const server = Fastify();
server.register(flocOff);
server.get("/", (_req, res) => {
res.send("ok");
});
server.listen(3000, (err) => {
if (err) throw err;
console.log("Server listening on 3000");
});
Contributing
Contributions are welcome, and any help is greatly appreciated!
See the contributing guide for details on how to get started. Please adhere to this project's Code of Conduct when contributing.
Acknowledgements
- Aras Abbasi - TypeScript support
License
fastify-floc-off
is licensed under the MIT license.