Use x_user_agent cookie for platform detection in Hotwire Native

Turbo's offline/service worker sets an x_user_agent cookie with the
original browser user agent. This ensures platform detection works
correctly for Hotwire Native apps where service worker requests may
not carry the overridden user agent header.
This commit is contained in:
Rosa Gutierrez
2026-03-10 15:27:42 +01:00
committed by Rosa Gutierrez
parent 8c2318e267
commit 66039c92f3
2 changed files with 22 additions and 1 deletions
+1 -1
View File
@@ -7,6 +7,6 @@ module SetPlatform
private
def platform
@platform ||= ApplicationPlatform.new(request.user_agent)
@platform ||= ApplicationPlatform.new(cookies[:x_user_agent].presence || request.user_agent)
end
end