wai-cors: CORS for WAI

[ http, library, mit, network, wai, web ] [ Propose Tags ]

This package provides an implemenation of Cross-Origin resource sharing (CORS) for Wai that aims to be compliant with http://www.w3.org/TR/cors.

[Skip to Readme]




Automatic Flags

use transformers<0.3 (this is set automatically)


use version wai<2 (this is set automatically)


Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS] 0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.2, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.2.5, 0.2.6, 0.2.7
Change log CHANGELOG.md
Dependencies attoparsec (>=, base (>=4 && <5), base-unicode-symbols (>=, bytestring (>=, case-insensitive (>=, charset (>=0.3.7), http-types (>=0.8.0), mtl (>=2.1), parsers (>=0.11), resourcet (>=0.4), transformers (>=0.3), transformers-compat (>=0.3), wai [details]
License MIT
Copyright Copyright (c) 2014 AlephCloud Systems, Inc.
Author Lars Kuhtz <lars@alephcloud.com>
Maintainer Lars Kuhtz <lars@alephcloud.com>
Category Web
Home page https://github.com/alephcloud/wai-cors
Bug tracker https://github.com/alephcloud/wai-cors/issues
Source repo head: git clone https://github.com/alephcloud/wai-cors
this: git clone https://github.com/alephcloud/wai-cors(tag 0.2.2)
Uploaded by JonSterling at 2015-04-20T23:14:15Z
Distributions Arch:0.2.7, Debian:0.2.7, Fedora:0.2.7, LTSHaskell:0.2.7, NixOS:0.2.7, Stackage:0.2.7, openSUSE:0.2.7
Reverse Dependencies 11 direct, 5 indirect [details]
Downloads 21870 total (109 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2015-04-20 [all 1 reports]

Readme for wai-cors-0.2.2

[back to package description]

Build Status

Cross-Origin Resource Sharing (CORS) For Wai

This package provides a Haskell implemenation of CORS for WAI that aims to be compliant with http://www.w3.org/TR/cors.


The file test/server.hs shows how to support simple cross-origin requests (as defined in http://www.w3.org/TR/cors) in a scotty application.

{-# LANGUAGE UnicodeSyntax #-}
{-# LANGUAGE OverloadedStrings #-}

module Main
( main
) where

import Network.Wai.Middleware.Cors
import Web.Scotty

main ∷ IO ()
main = scotty 8080 $ do
    middleware simpleCors
    matchAny  "/" $ text "Success"

The result of following curl command will include the HTTP response header Access-Control-Allow-Origin: *.

curl -i -H 'Origin:' -v

Documentation for more general usage can be found in the module Network.Wai.Middleware.Cors.


Currently there is only basic support to test simple cross-origin request from a browser.

Start server:

cd test
runHaskell server.hs

Open the file test/index.html in a modern web-browser in order to run some simple tests.