mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2026-01-07 00:36:08 +08:00
Add robots meta tags and headers, to prevent search engine indexing [SCI-12447]
This commit is contained in:
parent
963a3b4959
commit
c19e414b18
5 changed files with 25 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="robots" content="noindex,nofollow">
|
||||
<%= csp_meta_tag %>
|
||||
<meta data-hook="head-js">
|
||||
<title><%=t "head.title", title: (yield :head_title) %></title>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="robots" content="noindex,nofollow">
|
||||
<%= csp_meta_tag %>
|
||||
<meta data-hook="head-js">
|
||||
<title><%=t "head.title", title: (yield :head_title) %></title>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="robots" content="noindex,nofollow">
|
||||
<%= csp_meta_tag %>
|
||||
<meta data-hook="head-js">
|
||||
<title><%=t "head.title", title: (yield :head_title) %></title>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ require 'action_view/railtie'
|
|||
# require "rails/test_unit/railtie"
|
||||
require 'datadog/auto_instrument' if ENV['DD_TRACE_ENABLED'] == 'true'
|
||||
|
||||
require_relative '../lib/rack_x_robots_tag'
|
||||
|
||||
# Require the gems listed in Gemfile, including any gems
|
||||
# you've limited to :test, :development, or :production.
|
||||
Bundler.require(*Rails.groups)
|
||||
|
|
@ -58,6 +60,9 @@ module Scinote
|
|||
# Add rack-attack middleware for request rate limiting
|
||||
config.middleware.use Rack::Attack
|
||||
|
||||
# Add X-Robots-Tag header to all responses, to prevent search engine indexing
|
||||
config.middleware.use Rack::XRobotsTag
|
||||
|
||||
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
|
||||
|
||||
config.encoding = 'utf-8'
|
||||
|
|
|
|||
17
lib/rack_x_robots_tag.rb
Normal file
17
lib/rack_x_robots_tag.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Rack
|
||||
class XRobotsTag
|
||||
def initialize(app)
|
||||
@app = app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
status, headers, response = @app.call(env)
|
||||
|
||||
headers['X-Robots-Tag'] = 'none'
|
||||
|
||||
[status, headers, response]
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue