debian-mirror-gitlab/config/initializers/static_files.rb
2021-01-30 21:13:32 +05:30

28 lines
1.1 KiB
Ruby

app = Rails.application
if app.config.public_file_server.enabled
# The `ActionDispatch::Static` middleware intercepts requests for static files
# by checking if they exist in the `/public` directory.
# 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.
app.config.middleware.swap(
ActionDispatch::Static,
Gitlab::Middleware::Static,
app.paths["public"].first,
headers: app.config.public_file_server.headers
)
# If webpack-dev-server is configured, proxy webpack's public directory
# instead of looking for static assets
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
)
end
end