Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions app/controllers/external_uploads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class ExternalUploadsController < ApplicationController
skip_before_action :require_authentication!
skip_forgery_protection
before_action :set_cors_headers

def preflight
Expand Down
5 changes: 5 additions & 0 deletions test/controllers/external_uploads_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class ExternalUploadsControllerTest < ActionDispatch::IntegrationTest
end

test "preflight permits range requests" do
original_forgery_protection = ActionController::Base.allow_forgery_protection
ActionController::Base.allow_forgery_protection = true

options @file_path, headers: {
"Origin" => "https://example.com",
"Access-Control-Request-Method" => "GET",
Expand All @@ -17,5 +20,7 @@ class ExternalUploadsControllerTest < ActionDispatch::IntegrationTest
assert_equal "*", response.headers["Access-Control-Allow-Headers"]
assert_equal "GET, HEAD", response.headers["Access-Control-Allow-Methods"]
assert_equal "86400", response.headers["Access-Control-Max-Age"]
ensure
ActionController::Base.allow_forgery_protection = original_forgery_protection
end
end