问题
using the run from Network.Wai.Handler.Warp function to server rest api
run :: Port -> Application -> IO ()
but while doing post request, getting an error CORS header ‘Access-Control-Allow-Origin’.
any idea how to overcome this in servant/haskell
回答1:
You could use wai-cors middleware to add CORS headers.
At the end you'll have something like
app = simpleCors $ serve api serverImpl
where
simpleCorsis aMiddlewarefromwai-corsserveturns servant handlers intowaiApplicationapi :: Proxy YourAPIserverImplis your handlers' implementation
来源:https://stackoverflow.com/questions/47346778/cors-header-access-control-allow-origin-missing-in-servant