I'm trying to share session between subdomain, but I couldn't.
I followed this Devise config, but it didn't work.
This is how my /etc/hosts looks like:
127.0.0.1 localhost
127.0.0.1 apedraza.bejoy.local
127.0.0.1 bejoy.local
127.0.1.1 augusto-Lenovo-G580
127.0.0.1 api.the_genesis.com
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
and my config/initializers/session_store.rb
Rails.application.config.session_store :cookie_store, key: '_bejoy_session', domain: ".bejoy.local"
In my bejoy.local:5000/users/sign_in, I created an account(with subdomain apedraza) and it redirects to apedraza.bejoy.local:5000/admin, but that routes redirects to apedraza.bejoy.local:5000/users/sign_in, that is because the session can't be found.
I have the rails app into a Docker container, so not sure if that could be a problem.
Thanks @iashraf for your reply.
I had already tried that, but didn't work for me.
However, after create a new rails project from scratch, I could see that config was correct.
So thanks to that, I found that the problem was on other place:
I re-write the Registration controller for Devise, I screw it up because I used a redirect
to a subdomain on the super
block.
Finally, I deleted the redirect from the super
block and put the url_path on the after_sign_up_path_for
, and this worked!