使用run
从Network.Wai.Handler.Warp
函数到服务器rest api
run :: Port -> Application -> IO ()
但是在执行 post
请求时,收到错误CORS header ‘Access-Control-Allow-Origin’
。
知道如何在servant/haskell中克服这个问题
最佳答案
您可以使用wai-cors
用于添加 CORS header 的中间件。
最后你会得到类似的东西
app = simpleCors $ serve api serverImpl
哪里
simpleCors
是来自wai-cors
的中间件
serve
将servant处理程序转变为wai
Application
api::代理 YourAPI
serverImpl
是您的处理程序的实现
关于haskell - 仆人中缺少 CORS header ‘Access-Control-Allow-Origin’,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47346778/