2015-12-23 02:04:40 +05:30
|
|
|
app = Rails.application
|
2015-04-26 12:48:37 +05:30
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
if (Gitlab.rails5? && app.config.public_file_server.enabled) || app.config.serve_static_files
|
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.
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
if Gitlab.rails5?
|
|
|
|
app.config.middleware.swap(
|
|
|
|
ActionDispatch::Static,
|
|
|
|
Gitlab::Middleware::Static,
|
|
|
|
app.paths["public"].first,
|
|
|
|
headers: app.config.public_file_server.headers
|
|
|
|
)
|
|
|
|
else
|
|
|
|
app.config.middleware.swap(
|
|
|
|
ActionDispatch::Static,
|
|
|
|
Gitlab::Middleware::Static,
|
|
|
|
app.paths["public"].first,
|
|
|
|
app.config.static_cache_control
|
|
|
|
)
|
|
|
|
end
|
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
|
|
|
|
dev_server = Gitlab.config.webpack.dev_server
|
|
|
|
|
|
|
|
if dev_server.enabled
|
|
|
|
settings = {
|
|
|
|
enabled: true,
|
|
|
|
host: dev_server.host,
|
|
|
|
port: dev_server.port,
|
|
|
|
manifest_host: dev_server.host,
|
2017-09-10 17:25:29 +05:30
|
|
|
manifest_port: dev_server.port
|
2017-08-17 22:00:37 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
if Rails.env.development?
|
|
|
|
settings.merge!(
|
|
|
|
host: Gitlab.config.gitlab.host,
|
|
|
|
port: Gitlab.config.gitlab.port,
|
2018-03-17 18:26:18 +05:30
|
|
|
https: false
|
2017-08-17 22:00:37 +05:30
|
|
|
)
|
|
|
|
app.config.middleware.insert_before(
|
|
|
|
Gitlab::Middleware::Static,
|
2018-10-15 14:42:47 +05:30
|
|
|
Gitlab::Webpack::DevServerMiddleware,
|
2017-08-17 22:00:37 +05:30
|
|
|
proxy_path: app.config.webpack.public_path,
|
|
|
|
proxy_host: dev_server.host,
|
2017-09-10 17:25:29 +05:30
|
|
|
proxy_port: dev_server.port
|
2017-08-17 22:00:37 +05:30
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
app.config.webpack.dev_server.merge!(settings)
|
|
|
|
end
|
2015-04-26 12:48:37 +05:30
|
|
|
end
|