purescript / pursuit

Website for hosting and searching PureScript API documentation
https://pursuit.purescript.org/
Other
170 stars 47 forks source link

Adding the possibility for CORS requests to the pursuit API #463

Open mikesol opened 2 years ago

mikesol commented 2 years ago

I'm building a webapp where I'd like to add pursuit search, but fetch requests to pursuit are failing due to access control issues.

I think this could be solved by adding ie:

optionsSearchR :: Handler RepPlain
optionsSearchR = do
    addHeader "Access-Control-Allow-Origin" "*"
    addHeader "Access-Control-Allow-Methods" "GET, OPTIONS"
    return $ RepPlain $ toContent ("" :: Text)

getSearchR :: Handler TypedContent
getSearchR = do
    addHeader "Access-Control-Allow-Origin" "*"

Are there any objections to this? If not I'll make a PR.