|
53 | 53 | "#{Workarea::Admin.root}/public" |
54 | 54 | ) |
55 | 55 |
|
| 56 | +# Rails 7.0 uses Zeitwerk autoloading, but initializers run before Zeitwerk |
| 57 | +# has eager-loaded app/middleware constants. Require these middleware files |
| 58 | +# explicitly to guarantee the constants are defined when the middleware stack |
| 59 | +# is configured. |
| 60 | +# |
| 61 | +# On Rails 6.x these requires are no-ops (the constants are already loaded or |
| 62 | +# will be auto-required); on Rails 7.1+ this pattern remains safe. |
| 63 | +# |
| 64 | +# Decision rationale: Rails 7.0 introduced native `config.hosts` enforcement |
| 65 | +# which covers host header validation at the ActionDispatch level. However, |
| 66 | +# Workarea's EnforceHostMiddleware provides Workarea-specific redirect behavior |
| 67 | +# (respecting Workarea.config.enforce_host / config.host / skip_enforce_host) |
| 68 | +# that `config.hosts` does not replicate. We therefore keep the middleware and |
| 69 | +# fix the autoload gap instead of removing it. |
| 70 | +require_relative '../../app/middleware/workarea/enforce_host_middleware' |
56 | 71 | app.config.middleware.use Workarea::EnforceHostMiddleware |
57 | 72 |
|
58 | 73 | # ApplicationMiddleware must wrap the entire Workarea request pipeline so it |
59 | 74 | # can set up the Workarea::Visit, locale, and cache-key env vars before any |
60 | 75 | # controller or caching layer runs. |
| 76 | +require_relative '../../app/middleware/workarea/application_middleware' |
61 | 77 | app.config.middleware.insert(0, Workarea::ApplicationMiddleware) |
62 | 78 |
|
63 | 79 | # In test environments, strip all HTTP caching headers from responses so that |
64 | 80 | # headless-browser tests behave consistently regardless of cache state. |
| 81 | +require_relative '../../app/middleware/workarea/strip_http_caching_middleware' |
65 | 82 | app.config.middleware.insert(0, Workarea::StripHttpCachingMiddleware) if Rails.env.test? |
0 commit comments