Skip to content

Commit

Permalink
fix: OPTIONS not accepting all available media
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-chavez committed Jun 14, 2023
1 parent 11a9849 commit fad4732
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/PostgREST/ApiRequest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion test/spec/Feature/CorsSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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" <:> "*" ] }

0 comments on commit fad4732

Please sign in to comment.