aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2022-11-08 12:45:15 -0800
committerJohn MacFarlane <[email protected]>2022-11-08 12:45:15 -0800
commite2899fd52af6bcd962e4905f13deb5818ad42ded (patch)
tree2f7cee6138a69ac1af02f03511af578dbff61dd2
parentdee186be7d90583dbe25f318d99c30b3a61345dd (diff)
Add simple CORS support to pandoc-server.
Closes #8427.
-rw-r--r--pandoc-server/pandoc-server.cabal3
-rw-r--r--pandoc-server/src/Text/Pandoc/Server.hs3
2 files changed, 4 insertions, 2 deletions
diff --git a/pandoc-server/pandoc-server.cabal b/pandoc-server/pandoc-server.cabal
index bfe419760..2dfc002b8 100644
--- a/pandoc-server/pandoc-server.cabal
+++ b/pandoc-server/pandoc-server.cabal
@@ -61,7 +61,8 @@ library
unicode-collation >= 0.1.1 && < 0.2,
servant-server >= 0.19 && < 0.20,
skylighting >= 0.13 && < 0.14,
- wai >= 0.3
+ wai >= 3.2 && < 3.3,
+ wai-cors >= 0.2.7 && < 0.3
hs-source-dirs: src
diff --git a/pandoc-server/src/Text/Pandoc/Server.hs b/pandoc-server/src/Text/Pandoc/Server.hs
index c45dfa381..e3965b45b 100644
--- a/pandoc-server/src/Text/Pandoc/Server.hs
+++ b/pandoc-server/src/Text/Pandoc/Server.hs
@@ -47,6 +47,7 @@ import Text.Pandoc.Format (parseFlavoredFormat, formatName)
import Text.Pandoc.SelfContained (makeSelfContained)
import System.Exit
import GHC.Generics (Generic)
+import Network.Wai.Middleware.Cors (simpleCors)
data ServerOpts =
ServerOpts
@@ -197,7 +198,7 @@ type API =
"version" :> Get '[PlainText, JSON] Text
app :: Application
-app = serve api server
+app = simpleCors $ serve api server
api :: Proxy API
api = Proxy