debian-mirror-gitlab/config/initializers/static_files.rb

29 lines
1.1 KiB
Ruby
Raw Normal View History

2015-12-23 02:04:40 +05:30
app = Rails.application
2015-04-26 12:48:37 +05:30
2019-02-13 22:33:31 +05:30
if app.config.public_file_server.enabled
2018-03-17 18:26:18 +05:30
# The `ActionDispatch::Static` middleware intercepts requests for static files
# by checking if they exist in the `/public` directory.
2015-04-26 12:48:37 +05:30
# 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.
2019-02-13 22:33:31 +05:30
app.config.middleware.swap(
ActionDispatch::Static,
Gitlab::Middleware::Static,
app.paths["public"].first,
headers: app.config.public_file_server.headers
)
2017-08-17 22:00:37 +05:30
# If webpack-dev-server is configured, proxy webpack's public directory
# instead of looking for static assets
2021-01-03 14:25:43 +05:30
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-08-17 22:00:37 +05:30
end
2015-04-26 12:48:37 +05:30
end