mirror of
https://github.com/discourse/discourse.git
synced 2025-03-26 21:45:51 +08:00
ignore uploads for mini profiler
This commit is contained in:
parent
788b66e4a3
commit
2599b94920
@ -41,8 +41,8 @@ Discourse::Application.configure do
|
|||||||
config.load_mini_profiler = true
|
config.load_mini_profiler = true
|
||||||
|
|
||||||
require 'middleware/turbo_dev'
|
require 'middleware/turbo_dev'
|
||||||
require 'middleware/missing_avatars'
|
|
||||||
config.middleware.insert 0, Middleware::TurboDev
|
config.middleware.insert 0, Middleware::TurboDev
|
||||||
|
require 'middleware/missing_avatars'
|
||||||
config.middleware.insert 1, Middleware::MissingAvatars
|
config.middleware.insert 1, Middleware::MissingAvatars
|
||||||
|
|
||||||
config.enable_anon_caching = false
|
config.enable_anon_caching = false
|
||||||
|
@ -18,21 +18,28 @@ if defined?(Rack::MiniProfiler)
|
|||||||
# namespacing gets complex, cause mini profiler is in the rack chain way before multisite
|
# namespacing gets complex, cause mini profiler is in the rack chain way before multisite
|
||||||
Rack::MiniProfiler.config.storage_instance = Rack::MiniProfiler::RedisStore.new(connection: DiscourseRedis.raw_connection)
|
Rack::MiniProfiler.config.storage_instance = Rack::MiniProfiler::RedisStore.new(connection: DiscourseRedis.raw_connection)
|
||||||
|
|
||||||
|
skip = [
|
||||||
|
/^\/message-bus/,
|
||||||
|
/topics\/timings/,
|
||||||
|
/assets/,
|
||||||
|
/\/user_avatar\//,
|
||||||
|
/\/letter_avatar\//,
|
||||||
|
/\/highlight-js\//,
|
||||||
|
/qunit/,
|
||||||
|
/srv\/status/,
|
||||||
|
/commits-widget/,
|
||||||
|
/^\/cdn_asset/,
|
||||||
|
/^\/logs/,
|
||||||
|
/^\/site_customizations/,
|
||||||
|
/^\/uploads/
|
||||||
|
]
|
||||||
|
|
||||||
# For our app, let's just show mini profiler always, polling is chatty so nuke that
|
# For our app, let's just show mini profiler always, polling is chatty so nuke that
|
||||||
Rack::MiniProfiler.config.pre_authorize_cb = lambda do |env|
|
Rack::MiniProfiler.config.pre_authorize_cb = lambda do |env|
|
||||||
path = env['PATH_INFO']
|
path = env['PATH_INFO']
|
||||||
|
|
||||||
(env['HTTP_USER_AGENT'] !~ /iPad|iPhone|Nexus 7|Android/) &&
|
(env['HTTP_USER_AGENT'] !~ /iPad|iPhone|Nexus 7|Android/) &&
|
||||||
(path !~ /^\/message-bus/) &&
|
(env['REQUEST_METHOD'] != "GET" || !skip.any?{|re| re =~ path})
|
||||||
(path !~ /topics\/timings/) &&
|
|
||||||
(path !~ /assets/) &&
|
|
||||||
(path !~ /\/user_avatar\//) &&
|
|
||||||
(path !~ /\/letter_avatar\//) &&
|
|
||||||
(path !~ /\/highlight-js\//) &&
|
|
||||||
(path !~ /qunit/) &&
|
|
||||||
(path !~ /srv\/status/) &&
|
|
||||||
(path !~ /commits-widget/) &&
|
|
||||||
(path !~ /^\/cdn_asset/) &&
|
|
||||||
(path !~ /^\/logs/)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# without a user provider our results will use the ip address for namespacing
|
# without a user provider our results will use the ip address for namespacing
|
||||||
|
Loading…
x
Reference in New Issue
Block a user