diff --git a/CHANGELOG.md b/CHANGELOG.md index 79d0253132..381fe3cd66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased +### Fixed + + - #2821, Fix OPTIONS not accepting all available media types - @steve-chavez + ## [11.1.0] - 2023-06-07 ### Added diff --git a/src/PostgREST/ApiRequest.hs b/src/PostgREST/ApiRequest.hs index 2532cd02f4..6d36e2ac97 100644 --- a/src/PostgREST/ApiRequest.hs +++ b/src/PostgREST/ApiRequest.hs @@ -375,8 +375,8 @@ requestMediaTypes conf action path = ActionRead _ -> defaultMediaTypes ++ rawMediaTypes ActionInvoke _ -> invokeMediaTypes ActionInspect _ -> [MTOpenAPI, MTApplicationJSON] - ActionInfo -> [MTTextCSV] - _ -> defaultMediaTypes + ActionInfo -> defaultMediaTypes + ActionMutate _ -> defaultMediaTypes where invokeMediaTypes = defaultMediaTypes diff --git a/test/spec/Feature/CorsSpec.hs b/test/spec/Feature/CorsSpec.hs index a411238708..f25f2bbeb7 100644 --- a/test/spec/Feature/CorsSpec.hs +++ b/test/spec/Feature/CorsSpec.hs @@ -40,7 +40,7 @@ spec = \Date, Location, Server, Transfer-Encoding, Range-Unit"] } - it "allows INFO body through even with CORS request headers present to postflight request" $ + it "allows INFO body through even with CORS request headers present to postflight request" $ do request methodOptions "/items" [ ("Host", "localhost:3000") , ("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:32.0) Gecko/20100101 Firefox/32.0") @@ -54,3 +54,17 @@ spec = `shouldRespondWith` "" { matchHeaders = [ "Access-Control-Allow-Origin" <:> "*" ] } + + request methodOptions "/items" + [ ("Accept", "application/json") ] + "" + `shouldRespondWith` + "" + { matchHeaders = [ "Access-Control-Allow-Origin" <:> "*" ] } + + request methodOptions "/shops" + [ ("Accept", "application/geo+json") ] + "" + `shouldRespondWith` + "" + { matchHeaders = [ "Access-Control-Allow-Origin" <:> "*" ] }