2021-02-03 21:09:17 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-11-25 16:18:44 +00:00
|
|
|
app = Rails.application
|
2015-02-20 11:44:07 +00:00
|
|
|
|
2021-09-14 15:12:05 +00:00
|
|
|
# Disable Sendfile for Sidekiq Web assets since Workhorse won't
|
|
|
|
# always have access to these files.
|
|
|
|
app.config.middleware.insert_before(Rack::Sendfile, Gitlab::Middleware::SidekiqWebStatic)
|
|
|
|
|
2018-12-07 18:15:06 +00:00
|
|
|
if app.config.public_file_server.enabled
|
2017-08-15 17:44:37 +00:00
|
|
|
# The `ActionDispatch::Static` middleware intercepts requests for static files
|
|
|
|
# by checking if they exist in the `/public` directory.
|
2015-02-20 22:30:06 +00:00
|
|
|
# We're replacing it with our `Gitlab::Middleware::Static` that does the same,
|
|
|
|
# except ignoring `/uploads`, letting those go through to the GitLab Rails app.
|
|
|
|
|
2018-12-07 18:15:06 +00:00
|
|
|
app.config.middleware.swap(
|
|
|
|
ActionDispatch::Static,
|
|
|
|
Gitlab::Middleware::Static,
|
|
|
|
app.paths["public"].first,
|
|
|
|
headers: app.config.public_file_server.headers
|
|
|
|
)
|
2017-02-01 19:05:33 +00:00
|
|
|
|
|
|
|
# If webpack-dev-server is configured, proxy webpack's public directory
|
|
|
|
# instead of looking for static assets
|
2020-10-07 06:09:03 +00:00
|
|
|
if Gitlab.config.webpack.dev_server.enabled && Rails.env.development?
|
|
|
|
app.config.middleware.insert_before(
|
|
|
|
Gitlab::Middleware::Static,
|
|
|
|
Gitlab::Webpack::DevServerMiddleware,
|
|
|
|
proxy_path: Gitlab.config.webpack.public_path,
|
|
|
|
proxy_host: Gitlab.config.webpack.dev_server.host,
|
|
|
|
proxy_port: Gitlab.config.webpack.dev_server.port,
|
|
|
|
proxy_https: Gitlab.config.webpack.dev_server.https
|
|
|
|
)
|
2017-02-01 19:05:33 +00:00
|
|
|
end
|
2015-02-20 13:39:35 +00:00
|
|
|
end
|