FIX: Set X-Robots-Tag header to prevent indexing of /safe-mode (#32329)

This change adds the `X-Robots-Tag` header to the `/safe-mode` response, discouraging search engines from including the page in their index.
This commit is contained in:
Gary Pendergast 2025-04-16 16:51:32 +10:00 committed by GitHub
parent 8ccb66a44a
commit 9b351614ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -8,6 +8,7 @@ class SafeModeController < ApplicationController
skip_before_action :preload_json, :check_xhr
def index
response.headers["X-Robots-Tag"] = "noindex, nofollow"
end
def enter

View File

@ -21,6 +21,11 @@ RSpec.describe SafeModeController do
expect(response.body).not_to include("My Custom Header")
expect(response.body).not_to include("data-theme-id=\"#{theme.id}\"")
end
it "sets the robots header" do
get "/safe-mode"
expect(response.headers["X-Robots-Tag"]).to eq("noindex, nofollow")
end
end
describe "enter" do