Skip to content

Conversation

byroot
Copy link
Member

@byroot byroot commented Aug 19, 2025

Fix: rails/rails#55508

Mounting Propshaft::Server in the Rails router isn't suitable because it end up executed after a long list of middlewares that may set cookies or do other transformation we don't want.

In production, propshaft assets are served by ActionDispatch::Static (or a reverse proxy), so we should try to be as close to that as possible.

path = env["PATH_INFO"]
method = env["REQUEST_METHOD"]

if (method == "GET" || method == "HEAD") && path.start_with?(@assembly.prefix)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rack::Head would take care of that, but yes, good point.

Fix: rails/rails#55508

Mounting Propshaft::Server in the Rails router isn't suitable
because it end up executed after a long list of middlewares that
may set cookies or do other transformation we don't want.

In production, propshaft assets are served by `ActionDispatch::Static`
(or a reverse proxy), so we should try to be as close to that as possible.
@rafaelfranca rafaelfranca merged commit 84d9a55 into rails:main Sep 5, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ActiveRecord::Middleware::DatabaseSelector sets cookies on asset requests
3 participants