ocharles / snap-cors Goto Github PK
View Code? Open in Web Editor NEWAdd CORS headers to Snap applications
License: BSD 3-Clause "New" or "Revised" License
Add CORS headers to Snap applications
License: BSD 3-Clause "New" or "Revised" License
Hi there
I have this simple example that I can't get working, and I can't figure out why. The weird thing is that I'm fairly sure it was working fine at some point, but now it doesn't.
Here's the code:
main :: IO ()
main = serveSnaplet defaultConfig appInit
appInit :: SnapletInit () ()
appInit = makeSnaplet "ExampleServer" "" Nothing $ do
addRoutes [
("/fundingInfo"
, method GET (writeBS "{'woo' : 8}"))
]
wrapCORS
Using curl
I get the following response:
$ curl -i localhost/fundingInfo
HTTP/1.1 200 OK
Server: Snap/0.9.5.1
Date: Thu, 02 Jun 2016 14:37:53 GMT
Transfer-Encoding: chunked
{'woo' : 8}
So no CORS headers. What am I missing here?
[http://www.w3.org/TR/cors/#access-control-allow-origin-response-header] sais:
In practice the origin-list-or-null production is more constrained. Rather than allowing a space-separated list of origins, it is either a single origin or the string "null".
Your code sais:
| Origins OriginSet
-- ^ Allow cross-origin requests from these origins.
I am not sure how to interpret the w3c document, but my bet is that it wants you to use a single origin here, not 0 or more. What is yours? (-:
Thanks for writing this!
hey @ocharles, i think snap-cors can reasonably be made to relax that version constraint. Or at the very least things seem to build fine when i --allow-newer=snap to do a test build, and that also enables a much wider range of newer build plans to be possible for applications that depend on snap-cors.
thoughts?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.