2021-02-03 16:09:17 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-11-25 11:18:44 -05:00
|
|
|
app = Rails.application
|
2015-02-20 06:44:07 -05:00
|
|
|
|
2021-09-14 11:12:05 -04: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 13:15:06 -05:00
|
|
|
if app.config.public_file_server.enabled
|
2017-08-15 13:44:37 -04:00
|
|
|
# The `ActionDispatch::Static` middleware intercepts requests for static files
|
|
|
|
# by checking if they exist in the `/public` directory.
|
2015-02-20 17:30:06 -05: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 13:15:06 -05:00
|
|
|
app.config.middleware.swap(
|
|
|
|
ActionDispatch::Static,
|
|
|
|
Gitlab::Middleware::Static,
|
|
|
|
app.paths["public"].first,
|
|
|
|
headers: app.config.public_file_server.headers
|
|
|
|
)
|
2017-02-01 14:05:33 -05:00
|
|
|
|
|
|
|
# If webpack-dev-server is configured, proxy webpack's public directory
|
|
|
|
# instead of looking for static assets
|
2022-07-21 23:08:32 -04:00
|
|
|
if Gitlab.config.webpack.dev_server.enabled && Gitlab.dev_or_test_env?
|
2020-10-07 02:09:03 -04:00
|
|
|
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 14:05:33 -05:00
|
|
|
end
|
2015-02-20 08:39:35 -05:00
|
|
|
end
|