Skip to content

Commit eae8285

Browse files
Merge pull request #478 from BetterErrors/fix/csrf-token-cookie-path
Fix path of CSRF Token cookie
2 parents a9d1c4b + da0e0d9 commit eae8285

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/better_errors/middleware.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def self.allow_ip!(addr)
4040
allow_ip! "127.0.0.0/8"
4141
allow_ip! "::1/128" rescue nil # windows ruby doesn't have ipv6 support
4242

43-
CSRF_TOKEN_COOKIE_NAME = 'BetterErrors-CSRF-Token'
43+
CSRF_TOKEN_COOKIE_NAME = "BetterErrors-#{VERSION}-CSRF-Token"
4444

4545
# A new instance of BetterErrors::Middleware
4646
#
@@ -113,7 +113,7 @@ def show_error_page(env, exception=nil)
113113
response = Rack::Response.new(content, status_code, { "Content-Type" => "text/#{type}; charset=utf-8" })
114114

115115
unless request.cookies[CSRF_TOKEN_COOKIE_NAME]
116-
response.set_cookie(CSRF_TOKEN_COOKIE_NAME, value: csrf_token, httponly: true, same_site: :strict)
116+
response.set_cookie(CSRF_TOKEN_COOKIE_NAME, value: csrf_token, path: "/", httponly: true, same_site: :strict)
117117
end
118118

119119
# In older versions of Rack, the body returned here is actually a Rack::BodyProxy which seems to be a bug.

0 commit comments

Comments
 (0)