mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 09:10:25 +08:00
FEATURE: add clean support for running Discourse in a subfolder
To setup set DISCOURSE_RELATIVE_URL_ROOT to the folder you wish
This commit is contained in:
parent
4c4183228f
commit
f5af4768eb
27 changed files with 81 additions and 34 deletions
|
@ -17,11 +17,12 @@ module Middleware
|
|||
end
|
||||
|
||||
def call(env)
|
||||
is_asset = (env['REQUEST_PATH'] =~ /^\/assets\//)
|
||||
root = "#{GlobalSetting.relative_url_root}/assets/"
|
||||
is_asset = env['REQUEST_PATH'] && env['REQUEST_PATH'].starts_with?(root)
|
||||
|
||||
# hack to bypass all middleware if serving assets, a lot faster 4.5 seconds -> 1.5 seconds
|
||||
if (etag = env['HTTP_IF_NONE_MATCH']) && is_asset
|
||||
name = $'
|
||||
name = env['REQUEST_PATH'][(root.length)..-1]
|
||||
etag = etag.gsub "\"", ""
|
||||
asset = Rails.application.assets.find_asset(name)
|
||||
if asset && asset.digest == etag
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue