BUGFIX: re-enable CDN js debugging in a robust way
May be disabled if needed via site setting
This commit is contained in:
parent
5901ed6842
commit
832a730e36
|
@ -57,4 +57,17 @@ class StaticController < ApplicationController
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
skip_before_filter :verify_authenticity_token, only: [:cdn_asset]
|
||||||
|
def cdn_asset
|
||||||
|
path = params[:path].gsub(/[^a-zA-Z0-9_\-\.]/, "")
|
||||||
|
path = (Rails.root + "public/assets/" + path).to_s
|
||||||
|
expires_in 1.year, public: true
|
||||||
|
response.headers["Access-Control-Allow-Origin"] = params[:origin]
|
||||||
|
opts = {
|
||||||
|
disposition: nil
|
||||||
|
}
|
||||||
|
opts[:type] = "application/x-javascript" if path =~ /\.js$/
|
||||||
|
send_file(path, opts)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,14 +12,14 @@ module ApplicationHelper
|
||||||
include ConfigurableUrls
|
include ConfigurableUrls
|
||||||
|
|
||||||
def script(*args)
|
def script(*args)
|
||||||
# This crazy stuff is needed to get window.onerror working under a CDN
|
if SiteSetting.enable_cdn_js_debugging && GlobalSetting.cdn_url
|
||||||
# NGINX change is also required and baked into sample config
|
tags = javascript_include_tag(*args, "crossorigin" => "anonymous")
|
||||||
# @sam: disabling this until we update our CDN configuration
|
tags.gsub!("/assets/", "/cdn_asset/#{Discourse.current_hostname.gsub(".","_")}/")
|
||||||
#if GlobalSetting.cdn_url
|
tags.gsub!(".js\"", ".js?origin=#{CGI.escape request.base_url}\"")
|
||||||
# javascript_include_tag(*args, "crossorigin" => "anonymous")
|
tags.html_safe
|
||||||
#else
|
else
|
||||||
javascript_include_tag(*args)
|
javascript_include_tag(*args)
|
||||||
#end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def discourse_csrf_tags
|
def discourse_csrf_tags
|
||||||
|
|
|
@ -895,6 +895,7 @@ en:
|
||||||
embed_blacklist_selector: "css selector for elements that are removed from embeds"
|
embed_blacklist_selector: "css selector for elements that are removed from embeds"
|
||||||
tos_accept_required: "If enabled, users will need to check a box on the signup form to confirm that they accept the terms of service. Edit 'Signup Form: Terms of Service Message' in the Content tab to change the message."
|
tos_accept_required: "If enabled, users will need to check a box on the signup form to confirm that they accept the terms of service. Edit 'Signup Form: Terms of Service Message' in the Content tab to change the message."
|
||||||
notify_about_flags_after: "If there are flags that haven't been handled after this many hours, send an email to the contact_email. Set to 0 to disable."
|
notify_about_flags_after: "If there are flags that haven't been handled after this many hours, send an email to the contact_email. Set to 0 to disable."
|
||||||
|
enable_cdn_js_debugging: "Allow /logs to display proper errors by adding crossorigin permissions on all js includes"
|
||||||
|
|
||||||
notification_types:
|
notification_types:
|
||||||
mentioned: "%{display_username} mentioned you in %{link}"
|
mentioned: "%{display_username} mentioned you in %{link}"
|
||||||
|
|
|
@ -28,7 +28,7 @@ server {
|
||||||
listen 80;
|
listen 80;
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_min_length 1000;
|
gzip_min_length 1000;
|
||||||
gzip_types application/json text/css application/x-javascript;
|
gzip_types application/json text/css application/x-javascript application/javascript;
|
||||||
|
|
||||||
server_name enter.your.web.hostname.here;
|
server_name enter.your.web.hostname.here;
|
||||||
server_tokens off;
|
server_tokens off;
|
||||||
|
@ -63,8 +63,6 @@ server {
|
||||||
expires 1y;
|
expires 1y;
|
||||||
add_header ETag "";
|
add_header ETag "";
|
||||||
add_header Cache-Control public;
|
add_header Cache-Control public;
|
||||||
# enables window.onerror
|
|
||||||
add_header Access-Control-Allow-Origin *;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -365,6 +365,8 @@ Discourse::Application.routes.draw do
|
||||||
post "draft" => "draft#update"
|
post "draft" => "draft#update"
|
||||||
delete "draft" => "draft#destroy"
|
delete "draft" => "draft#destroy"
|
||||||
|
|
||||||
|
get "cdn_asset/:site/*path" => "static#cdn_asset", format: false
|
||||||
|
|
||||||
get "robots.txt" => "robots_txt#index"
|
get "robots.txt" => "robots_txt#index"
|
||||||
|
|
||||||
Discourse.filters.each do |filter|
|
Discourse.filters.each do |filter|
|
||||||
|
|
|
@ -537,3 +537,5 @@ uncategorized:
|
||||||
public_user_custom_fields:
|
public_user_custom_fields:
|
||||||
list: true
|
list: true
|
||||||
default: ''
|
default: ''
|
||||||
|
|
||||||
|
enable_cdn_js_debugging: true
|
||||||
|
|
Loading…
Reference in New Issue