There is clear doc on enable CORS in yesod
https://github.com/yesodweb/yesod-cookbook/blob/master/cookbook/Allowing-WOFF-fonts-to-be-accessed-from-other-domains-%28CORS%29.md#using-wai-cors-package
but it requires to run in a scaffold yesod application which has makeApplication and Application.hs
In my cases, the code base was built not by yesods scaffold now try to be exposed as a RESTful service.
mkYesod "App" [parseRoutes|
/Hello HelloR POST OPTIONS
/version VersionR GET
|]
How to add CORS support in this case ?
Ref:
Here is the code how I solve this.
Using
toWaiAppto extract theapplicationinstance and wrap it with cors midddle ware.