Skip to content

Commit b26f141

Browse files
authored
Merge pull request #118 from osbre/vary-header
Set the correct `Vary` header
2 parents 6c76a33 + 48e2912 commit b26f141

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

lib/inertia_rails/renderer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def initialize(component, controller, request, response, render_method, props: n
1717

1818
def render
1919
if @request.headers['X-Inertia']
20-
@response.set_header('Vary', 'Accept')
20+
@response.set_header('Vary', 'X-Inertia')
2121
@response.set_header('X-Inertia', 'true')
2222
@render_method.call json: page, status: @response.status, content_type: Mime[:json]
2323
else

spec/inertia/rendering_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
it 'has the proper headers' do
5151
expect(response.headers['X-Inertia']).to eq 'true'
52-
expect(response.headers['Vary']).to eq 'Accept'
52+
expect(response.headers['Vary']).to eq 'X-Inertia'
5353
expect(response.headers['Content-Type']).to eq 'application/json; charset=utf-8'
5454
end
5555

spec/inertia/ssr_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
it 'allows inertia to take over when inertia headers are passed' do
4343
get props_path, headers: {'X-Inertia' => true, 'X-Inertia-Version' => '1.0'}
4444

45-
expect(response.headers['Vary']).to eq 'Accept'
45+
expect(response.headers['Vary']).to eq 'X-Inertia'
4646
expect(response.headers['Content-Type']).to eq 'application/json; charset=utf-8'
4747
end
4848
end

0 commit comments

Comments
 (0)