Skip to content

Commit 2da6bd6

Browse files
bkylerussellsteve-chavez
authored andcommitted
Config: apply CorsResourcePolicy to PUT requests
PUT requests are part of the public upsert API, so if postgrest runs at a different origin, these requests will fail because they don't pass CORS.
1 parent 5bfb68b commit 2da6bd6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Diff for: src/PostgREST/Config.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ data AppConfig = AppConfig {
8282

8383
defaultCorsPolicy :: CorsResourcePolicy
8484
defaultCorsPolicy = CorsResourcePolicy Nothing
85-
["GET", "POST", "PATCH", "DELETE", "OPTIONS"] ["Authorization"] Nothing
85+
["GET", "POST", "PATCH", "PUT", "DELETE", "OPTIONS"] ["Authorization"] Nothing
8686
(Just $ 60*60*24) False False True
8787

8888
-- | CORS policy to be used in by Wai Cors middleware

Diff for: test/Feature/CorsSpec.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ spec =
4545
"true"
4646
respHeaders `shouldSatisfy` matchHeader
4747
"Access-Control-Allow-Methods"
48-
"GET, POST, PATCH, DELETE, OPTIONS, HEAD"
48+
"GET, POST, PATCH, PUT, DELETE, OPTIONS, HEAD"
4949
respHeaders `shouldSatisfy` matchHeader
5050
"Access-Control-Allow-Headers"
5151
"Authentication, Foo, Bar, Accept, Accept-Language, Content-Language"

0 commit comments

Comments
 (0)