Closed denny closed 3 years ago
The reason we need to define the middleware is so that the admin panel renders for Rails apps generated with API only mode.
I believe you might be able to inherit the session store configured in the main app, as long as this happens in the after_initialize
block. After the application is loaded, Rails.application.config.session_store
returns the configured class for session store. We can reuse it to make sure we don't use a different session store than the main app and fallback to cookie store.
Can you try to see if the adding this still fixes the issue?
# lib/sail/engine.rb
config.after_initialize do
errors = ......
config.middleware.use Rails.application.config.session_store || ActionDispatch::Session::CookieStore
end
@vinistock Yes, that works :smiley:
Simply removing the cookie session store allows Sail to be mounted in an app with ActiveRecord sessions.
With the cookie store specified, attempting to access the Sail path in such an app throws errors - see issue #326
I assume this PR is not an acceptable solution, presumably the cookie store is there for a reason! :) But I thought it might make a useful starting point for working things out...