工作上 rails 在每個 stage 的 domain 長度都不太一樣 例如 production 是 example.com,staging 是 kerkerj.staging.example.com MyApp::Application.config.session_store :redis_session_store, { key: 'example_session_token', domain: :all, tld_length: 4, serializer: :hybrid, redis: { host: "....", key_prefix: "...", expire_after: 7.day, } } 相關原始碼: action_dispatch/middleware/cookies.rb 在這裡的 tld_length 就是看你 domain 的 tld 想設定到哪就寫多少 以 kerkerj.staging.example.com 為例,想要 example.com 就是 2,想要 kerkerj.staging.example.com 就是 4 而在 Rails App 裡,在 config.action_dispatch.tld_length (或 ActionDispatch::Http::URL.tld_length ) 設定的 tld_length 在 rails api document 的 #domain 有用法

Continue reading

Author's picture

kerkerj

Cat lover <3

Backend Engineer

Taiwan