<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Thanks dan,</div><br><div><div>On Dec 12, 2012, at 9:47 AM, Daniel Bevenius &lt;<a href="mailto:daniel.bevenius@gmail.com">daniel.bevenius@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><p style="margin-right: 0px; margin-bottom: 15px; margin-left: 0px; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 14px; line-height: 22px; margin-top: 0px !important; ">To specify request header that are valid you can use the&nbsp;<code style="font-size:12px;line-height:normal;font-family:Consolas,'Liberation Mono',Courier,monospace;margin:0px 2px;padding:0px 5px;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;white-space:nowrap">validRequestHeaders</code>&nbsp;method:</p>
<div class="" style="border: none; padding: 0px; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 14px; line-height: 22px; "><pre style="font-size:13px;line-height:19px;font-family:Consolas,'Liberation Mono',Courier,monospace;word-wrap:break-word;margin-top:15px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(204,204,204);overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px"><span class="" style="font-weight:bold">return</span> <span class="">CorsConfig</span><span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(0,128,128)">enableCorsSupport</span><span class="" style="font-weight:bold">()</span>
                <span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(0,128,128)">anyOrigin</span><span class="" style="font-weight:bold">()</span>
                <span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(0,128,128)">enableCookies</span><span class="" style="font-weight:bold">()</span>
                <span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(0,128,128)">maxAge</span><span class="" style="font-weight:bold">(</span><span class="" style="color:rgb(0,153,153)">20</span><span class="" style="font-weight:bold">)</span>
                <span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(0,128,128)">enableAllRequestMethods</span><span class="" style="font-weight:bold">()</span>
                <span class="" style="font-weight:bold">.</span><span class="" style="color:rgb(0,128,128)">validRequestHeaders</span><span class="" style="font-weight:bold">(</span><span class="" style="color:rgb(221,17,68)">"header1, header2"</span><span class="" style="font-weight:bold">);</span></pre></div></blockquote><blockquote type="cite"><p style="margin: 15px 0px; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 14px; line-height: 22px; ">Is this how you modified you local aerogear-controller-demo?</p><p style="margin-top: 15px; margin-right: 0px; margin-left: 0px; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 14px; line-height: 22px; margin-bottom: 0px !important; ">
</p></blockquote><div>i actually did this in the CorsConfig class. &nbsp;Should have know it was easier than that</div><div><br></div><div>&nbsp; &nbsp; &nbsp;public CorsConfiguration build() {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; validRequestHeaders.add("origin");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; validRequestHeaders.add("accept");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; validRequestHeaders.add("content-type");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (validRequestMethods.isEmpty()) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; enableAllRequestMethods();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new CorsConfig(this);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><br><blockquote type="cite"><p style="margin-top: 15px; margin-right: 0px; margin-left: 0px; font-family: Helvetica, arial, freesans, clean, sans-serif; font-size: 14px; line-height: 22px; margin-bottom: 0px !important; ">I'm not sure exaclty what is going on just by looking at the request and the response. Let me try this out and see if I can figure it out.</p><div><p class=""><span class=""><br></span></p></div></blockquote><div><br></div><div>cool, &nbsp;i just used python -m SimpleHTTPServer to run the html/js stuff</div><br><blockquote type="cite"><div class="gmail_extra">
<br><br><div class="gmail_quote">On 12 December 2012 15:26, Lucas Holmquist <span dir="ltr">&lt;<a href="mailto:lholmqui@redhat.com" target="_blank">lholmqui@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><h3 style="margin:0px 0px 10px;padding:0px;font-size:18px;font-family:Helvetica,arial,freesans,clean,sans-serif">CORS with Aerogear.js and AG-Controller</h3><p style="margin:0px 0px 15px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">
from this gist:<a href="https://gist.github.com/4268092" target="_blank">https://gist.github.com/4268092</a></p><p style="margin:0px 0px 15px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">
2 things.</p><p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">So when using aerogear.js to make a cross domain call,</p><pre style="font-size:13px;line-height:19px;font-family:Consolas,'Liberation Mono',Courier,monospace;word-wrap:break-word;margin-top:15px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(204,204,204);overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px"><code style="font-size:12px;line-height:normal;font-family:Consolas,'Liberation Mono',Courier,monospace;margin:0px;padding:0px;border:none;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">var pipeline = AeroGear.Pipeline();
        cors = pipeline.add( {
            name: "cors",
            settings: {
                baseURL: "<a href="http://localhost:8080/aerogear-controller-demo/" target="_blank">http://localhost:8080/aerogear-controller-demo/</a>",
                endpoint: "login/"
            }
        });

        pipeline.pipes.cors.read({
            success: function( data, xhr, thing1 ) {
                console.log( data );
            },
            error: function( error ) {
                console.log( error );
            }
        });
</code></pre><p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">the initial OPTIONS request looks similar to this. Request URL:<a href="http://localhost:8080/aerogear-controller-demo/login/" target="_blank">http://localhost:8080/aerogear-controller-demo/login/</a></p>
<pre style="font-size:13px;line-height:19px;font-family:Consolas,'Liberation Mono',Courier,monospace;word-wrap:break-word;margin-top:15px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(204,204,204);overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px"><code style="font-size:12px;line-height:normal;font-family:Consolas,'Liberation Mono',Courier,monospace;margin:0px;padding:0px;border:none;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">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, content-type, accept
Access-Control-Request-Method:GET
Cache-Control:max-age=0
Connection:keep-alive
Host:localhost:8080
Origin:<a href="http://localhost:8000/" target="_blank">http://localhost:8000</a>
Pragma:no-cache
Referer:<a href="http://localhost:8000/app/cors.html" target="_blank">http://localhost:8000/app/cors.html</a>
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11
</code></pre><p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">I just copy and pasted this from chrome dev tools.</p><p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">
Here is what the CORS config looks like in the controller demo, for those who don't want to go look it up</p><pre style="font-size:13px;line-height:19px;font-family:Consolas,'Liberation Mono',Courier,monospace;word-wrap:break-word;margin-top:15px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(204,204,204);overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px"><code style="font-size:12px;line-height:normal;font-family:Consolas,'Liberation Mono',Courier,monospace;margin:0px;padding:0px;border:none;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">@Produces
public CorsConfiguration demoConfig() {
    return CorsConfig.enableCorsSupport()
            .anyOrigin()
            .enableCookies()
            .maxAge(20)
            .enableAllRequestMethods()
            .build();
}
</code></pre><p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">So the above request will fail since it has more headers than just "origin". This brings me to my first question:</p><p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">How do i specify more headers in this config object?, i guess in this case it would be origin, content-type, and accept</p><p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">Now to the second part</p><p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">
I modified my local aerogear-controller to add these other headers in by default, and then ran the above request again.</p><p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">
This time i get the same OPTIONS request but then i get a cross domain error with the follow up GET that the browser makes</p><pre style="font-size:13px;line-height:19px;font-family:Consolas,'Liberation Mono',Courier,monospace;word-wrap:break-word;margin-top:15px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(204,204,204);overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px"><code style="font-size:12px;line-height:normal;font-family:Consolas,'Liberation Mono',Courier,monospace;margin:0px;padding:0px;border:none;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Request URL:<a href="http://localhost:8080/aerogear-controller-demo/login/" target="_blank">http://localhost:8080/aerogear-controller-demo/login/</a>

Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Cache-Control:no-cache
Content-Type:application/json
Origin:<a href="http://localhost:8000/" target="_blank">http://localhost:8000</a>
Pragma:no-cache
Referer:<a href="http://localhost:8000/app/cors.html" target="_blank">http://localhost:8000/app/cors.html</a>
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11
</code></pre><p style="margin:15px 0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">And i don't get any errors on the server log, so not really sure whats going on here</p><p style="margin-top:15px;margin-right:0px;margin-bottom:0px!important;margin-left:0px;font-family:Helvetica,arial,freesans,clean,sans-serif;font-size:14px;line-height:22px">
This is the repo i was using to play around with&nbsp;<a href="https://github.com/lholmquist/WoWAerogear" style="color:rgb(65,131,196);text-decoration:initial" target="_blank">https://github.com/lholmquist/WoWAerogear</a>&nbsp;checkout the cors.html and cors.js page</p>
<div><br></div><div><br></div><div>-Luke</div></div><br>_______________________________________________<br>
aerogear-dev mailing list<br>
<a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br>
<br></blockquote></div><br></div>
_______________________________________________<br>aerogear-dev mailing list<br><a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/aerogear-dev<br></blockquote></div><br></body></html>