Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PERF: Do not set any caching headers on preflight requests #307

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/message_bus/rack/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ def handle_request(env)
return [404, {}, ["not found"]] unless client_id

headers = {}
extra_headers = {}
headers["Cache-Control"] = "must-revalidate, private, max-age=0"
headers["Content-Type"] = "application/json; charset=utf-8"
headers["Pragma"] = "no-cache"
headers["Expires"] = "0"

if @bus.extra_response_headers_lookup
@bus.extra_response_headers_lookup.call(env).each do |k, v|
headers[k] = v
end
extra_headers = @bus.extra_response_headers_lookup.call(env)
headers.merge!(extra_headers)
end

if env["REQUEST_METHOD"] == "OPTIONS"
return [200, headers, ["OK"]]
return [200, extra_headers.merge({ "Content-Type" => "text/html" }), ["OK"]]
end

user_id = @bus.user_id_lookup.call(env) if @bus.user_id_lookup
Expand Down