CORS header ‘Access-Control-Allow-Origin’ missing in servant

隐身守侯 提交于 2020-12-30 09:36:09

问题


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

  • simpleCors is a Middleware from wai-cors
  • serve turns servant handlers into wai Application
  • api :: Proxy YourAPI
  • serverImpl is your handlers' implementation


来源:https://stackoverflow.com/questions/47346778/cors-header-access-control-allow-origin-missing-in-servant

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!