diff options
| author | John MacFarlane <[email protected]> | 2022-11-09 17:49:40 -0800 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2022-11-09 17:49:40 -0800 |
| commit | 7ef00d7226f2fb64b6a62b629a18e4427f07f090 (patch) | |
| tree | 12b7306269ff939cc94f21472cef8b2cfba5af7b /pandoc-server | |
| parent | 334903bb9d7b7475666dcbb2c30b8d92339615a8 (diff) | |
pandoc-server: add ContentType to CORS policy.
See #8427.
Diffstat (limited to 'pandoc-server')
| -rw-r--r-- | pandoc-server/src/Text/Pandoc/Server.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/pandoc-server/src/Text/Pandoc/Server.hs b/pandoc-server/src/Text/Pandoc/Server.hs index e3965b45b..03b3222aa 100644 --- a/pandoc-server/src/Text/Pandoc/Server.hs +++ b/pandoc-server/src/Text/Pandoc/Server.hs @@ -47,7 +47,8 @@ import Text.Pandoc.Format (parseFlavoredFormat, formatName) import Text.Pandoc.SelfContained (makeSelfContained) import System.Exit import GHC.Generics (Generic) -import Network.Wai.Middleware.Cors (simpleCors) +import Network.Wai.Middleware.Cors ( cors, + simpleCorsResourcePolicy, CorsResourcePolicy(corsRequestHeaders) ) data ServerOpts = ServerOpts @@ -198,7 +199,14 @@ type API = "version" :> Get '[PlainText, JSON] Text app :: Application -app = simpleCors $ serve api server +app = corsWithContentType $ serve api server + +-- | Allow Content-Type header with values other then allowed by simpleCors. +corsWithContentType :: Middleware +corsWithContentType = cors (const $ Just policy) + where + policy = simpleCorsResourcePolicy + { corsRequestHeaders = ["Content-Type"] } api :: Proxy API api = Proxy |
