Skip to content

Instantly share code, notes, and snippets.

@jklydev
Created February 8, 2017 20:50
Show Gist options
  • Save jklydev/7b92bd6892a22fd2c8150b5bbe1419ba to your computer and use it in GitHub Desktop.
Save jklydev/7b92bd6892a22fd2c8150b5bbe1419ba to your computer and use it in GitHub Desktop.
cors.hs
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Network.HTTP.Simple
import Web.Scotty
import Data.Monoid (mconcat)
import Network.Wai.Middleware.Cors
main = scotty 3000 $ do
middleware simpleCors
get "/" $ html "hi"
get "/thing/" $ file "./thing.html"
-- curl -i http://127.0.0.1:3000 -H 'Origin: 127.0.0.1' -v
-- Will show " Access-Control-Allow-Origin: * "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment