Revert "DEV: enable cors to all cdn get requests from workbox. (#10684)" (#11076)

This reverts commit e3de45359f9bc7a71d9b8045a7e369fd0cf8f433.

We need to improve out strategy by adding a cache breaker with this change ... some assets on CDNs and clients may have incorrect CORS headers which can cause stuff to break.
This commit is contained in:
Vinoth Kannan
2020-10-30 10:35:35 +05:30
committed by GitHub
parent 347423007a
commit af4938baf1
21 changed files with 8 additions and 391 deletions

View File

@ -17,7 +17,6 @@ end
module Discourse
DB_POST_MIGRATE_PATH ||= "db/post_migrate"
REQUESTED_HOSTNAME ||= "REQUESTED_HOSTNAME"
require 'sidekiq/exception_handler'
class SidekiqExceptionHandler
@ -910,24 +909,6 @@ module Discourse
def self.is_parallel_test?
ENV['RAILS_ENV'] == "test" && ENV['TEST_ENV_NUMBER']
end
CDN_REQUEST_METHODS ||= ["GET", "HEAD", "OPTIONS"]
def self.is_cdn_request?(env, request_method)
return unless CDN_REQUEST_METHODS.include?(request_method)
cdn_hostnames = GlobalSetting.cdn_hostnames
return if cdn_hostnames.blank?
requested_hostname = env[REQUESTED_HOSTNAME] || env[Rack::HTTP_HOST]
cdn_hostnames.include?(requested_hostname)
end
def self.apply_cdn_headers(headers)
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = CDN_REQUEST_METHODS.join(", ")
headers
end
end
# rubocop:enable Style/GlobalVars