Skip to content

Instantly share code, notes, and snippets.

@multiversecoder
Created April 19, 2021 10:54
Show Gist options
  • Save multiversecoder/fe300a8918d176762507ec1657393e7b to your computer and use it in GitHub Desktop.
Save multiversecoder/fe300a8918d176762507ec1657393e7b to your computer and use it in GitHub Desktop.
How To Disable Google's FLoC | Ruby on Rails
# This is an Example on how to disable Google's FLoC using a 3 lines rails method
# setting the new "Permission-Policy" response header
#
# To disable Google's FLoC and Opt-Out from this security threat,
# just paste this code from line 12 to line 17 inside your application's
# app/controllers/application_controller.rb
#
class ApplicationController < ActionController::Base
# ...
after_action :nofloc
# disable Google's FLoC on Rails with "Permission-Policy" => "interest-cohort=()"
def nofloc
response.set_header 'Permission-Policy', 'interest-cohort=()'
end
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment