mirror of
https://github.com/discourse/discourse.git
synced 2025-09-07 12:02:53 +08:00
FIX: add 'noindex' header to rss feed responses.
This commit is contained in:
parent
45b37a8bd1
commit
b6765aac4b
3 changed files with 12 additions and 2 deletions
|
@ -44,6 +44,7 @@ class ApplicationController < ActionController::Base
|
|||
after_action :perform_refresh_session
|
||||
after_action :dont_cache_page
|
||||
after_action :conditionally_allow_site_embedding
|
||||
after_action :add_noindex_header, if: -> { is_feed_request? }
|
||||
|
||||
layout :set_layout
|
||||
|
||||
|
@ -801,6 +802,14 @@ class ApplicationController < ActionController::Base
|
|||
request.env['DISCOURSE_IS_ASSET_PATH'] = 1
|
||||
end
|
||||
|
||||
def is_feed_request?
|
||||
request.format.atom? || request.format.rss?
|
||||
end
|
||||
|
||||
def add_noindex_header
|
||||
response.headers['X-Robots-Tag'] = 'noindex'
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def render_post_json(post, add_raw: true)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue