diff options
Diffstat (limited to 'archives/extend/2013-April/000112.html')
-rw-r--r-- | archives/extend/2013-April/000112.html | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/archives/extend/2013-April/000112.html b/archives/extend/2013-April/000112.html new file mode 100644 index 00000000..d2d82a89 --- /dev/null +++ b/archives/extend/2013-April/000112.html @@ -0,0 +1,119 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<HTML> + <HEAD> + <TITLE> [99s-extend] Cowboy CORS + </TITLE> + <LINK REL="Index" HREF="index.html" > + <LINK REL="made" HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20Cowboy%20CORS&In-Reply-To=%3C0103B45C-A73C-498E-908D-AA1639D3DEE1%40gmail.com%3E"> + <META NAME="robots" CONTENT="index,nofollow"> + <style type="text/css"> + pre { + white-space: pre-wrap; /* css-2.1, curent FF, Opera, Safari */ + } + </style> + <META http-equiv="Content-Type" content="text/html; charset=us-ascii"> + <LINK REL="Previous" HREF="000111.html"> + <LINK REL="Next" HREF="000113.html"> + </HEAD> + <BODY BGCOLOR="#ffffff"> + <H1>[99s-extend] Cowboy CORS</H1> + <B>Lee Sylvester</B> + <A HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20Cowboy%20CORS&In-Reply-To=%3C0103B45C-A73C-498E-908D-AA1639D3DEE1%40gmail.com%3E" + TITLE="[99s-extend] Cowboy CORS">lee.sylvester at gmail.com + </A><BR> + <I>Fri Apr 19 16:47:09 CEST 2013</I> + <P><UL> + <LI>Previous message: <A HREF="000111.html">[99s-extend] Reading body_qs multiple times +</A></li> + <LI>Next message: <A HREF="000113.html">[99s-extend] Cowboy CORS +</A></li> + <LI> <B>Messages sorted by:</B> + <a href="date.html#112">[ date ]</a> + <a href="thread.html#112">[ thread ]</a> + <a href="subject.html#112">[ subject ]</a> + <a href="author.html#112">[ author ]</a> + </LI> + </UL> + <HR> +<!--beginarticle--> +<PRE>Hi guys, + +So, I thought I had this resolved, as I managed to get it working locally, but across different local domains (test.localhost.com and cowboy.localhost.com). However, now I've deployed my app to a VM, I simply can't get CORS working in Cowboy. Here's the OPTIONS response from Chrome's console: + + +Request URL:<A HREF="http://www.example.com/">http://www.example.com/</A> +Request Method:OPTIONS +Status Code:200 OK +Request Headersview source +Accept:*/* +Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3 +Accept-Encoding:gzip,deflate,sdch +Accept-Language:en-US,en;q=0.8 +Access-Control-Request-Headers:origin, method, content-type +Access-Control-Request-Method:POST +Connection:keep-alive +Host:www.example.com +Origin:<A HREF="http://test.localhost.com:8889">http://test.localhost.com:8889</A> +Referer:<A HREF="http://test.localhost.com:8889/">http://test.localhost.com:8889/</A> +User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31 +Response Headersview source +Access-Control-Allow-Headers:Content-Type, X-Requested-With, Origin, Method +Access-Control-Allow-Methods:GET, POST, OPTIONS +Access-Control-Allow-Origin:* +connection:keep-alive +content-length:0 +date:Fri, 19 Apr 2013 14:40:00 GMT +server:Cowboy + +And then this is the POST response: + +Request URL:<A HREF="http://www.example.com/">http://www.example.com/</A> +Request Headersview parsed +POST <A HREF="http://www.example.com/">http://www.example.com/</A> HTTP/1.1 +Origin: <A HREF="http://test.localhost.com:8889">http://test.localhost.com:8889</A> +Referer: <A HREF="http://test.localhost.com:8889/">http://test.localhost.com:8889/</A> +method: POST <A HREF="http://www.example.com/">http://www.example.com/</A> HTTP/1.1 +User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31 +content-type: application/x-www-form-urlencoded +Form Dataview parsed +data={"Type":"auth_request","Authentication":"public","Authorization":null,"Domain":"www.example.com","Application":"test_app","Ident":"lee"} + +I am setting {<<"Access-Control-Allow-Origin">>, <<"*">>} in the headers param of cowboy_req:reply and the cowboy_req:set_resp_header, but neither seems to be working. Can anyone spot what I might be doing wrong? + +The cowboy_req:set_resp_header is happening in the handle… So + +handle(Req, State) -> + Reply = case cowboy_req:method(Req) of + {<<"POST">>, Req2} -> + Req3 = cowboy_req:set_resp_header(<<"Access-Control-Allow-Origin">>, <<"*">>, Req2), +[snip] + + +Thanks, +Lee + +-------------- next part -------------- +An HTML attachment was scrubbed... +URL: <<A HREF="http://lists.ninenines.eu/archives/extend/attachments/20130419/bf0e8ef9/attachment.html">http://lists.ninenines.eu/archives/extend/attachments/20130419/bf0e8ef9/attachment.html</A>> +</PRE> + +<!--endarticle--> + <HR> + <P><UL> + <!--threads--> + <LI>Previous message: <A HREF="000111.html">[99s-extend] Reading body_qs multiple times +</A></li> + <LI>Next message: <A HREF="000113.html">[99s-extend] Cowboy CORS +</A></li> + <LI> <B>Messages sorted by:</B> + <a href="date.html#112">[ date ]</a> + <a href="thread.html#112">[ thread ]</a> + <a href="subject.html#112">[ subject ]</a> + <a href="author.html#112">[ author ]</a> + </LI> + </UL> + +<hr> +<a href="https://lists.ninenines.eu/listinfo/extend">More information about the Extend +mailing list</a><br> +</body></html> |