Matthias (OP) modestly sent me this off list. It is essentially exactly what I envisioned:
http://cxf.apache.org/docs/jax-rs-cors.html I talked to my team about implementing this kind of thing for our API several weeks ago but we got into a chicken-and-egg game with annotation processing and just used an interceptor to do it instead. Only change I'd do is call the annotation @CrossOrigin because it reads better (IMO, no real strong feelings though). This could eventually go into JAX-RS I think. On 06/19/2013 02:19 PM, Bill Burke wrote: > Somebody propose something and I'll implement it. I know nothing about > CORS. > > On 6/19/2013 2:07 PM, Chris Bredesen wrote: >> I do feel like there should be a facility to add CORS headers to >> select/all resources in RestEasy but I admit I Have not thought it >> through deeply and I kinda take the fact that it doesn't already exist >> to mean that there's probably some very good reason not to do it .... >> >> @CrossOrigin(...) almost seems too good to be true >> >> On 06/19/2013 01:20 PM, Matthias Wessendorf wrote: >>> Doh! >>> >>> I forgot to include the "Access-Control-Allow-Origin" header on the >>> actual response of the POST.... >>> >>> I was just "decorating" the response for the damn preflight request :) >>> >>> >>> Sorry for the noise >>> >>> -M >>> >>> >>> >>> On Wed, Jun 19, 2013 at 2:24 PM, Bill Burke <bbu...@redhat.com >>> <mailto:bbu...@redhat.com>> wrote: >>> >>> I'm not exactly sure what you're asking me to look at. The code looks >>> fine, but you can inject @Context HttpHeaders instead of the >>> HttpServletRequest. I honestly don't have any experience with CORS, >>> so >>> I can't really help you that much.... >>> >>> ...But...if you do figure out your problem and think there's something >>> we can add to Resteasy to support CORS, let me know and either spec it >>> out for us, or submit your own pull request. >>> >>> On 6/19/2013 6:40 AM, Matthias Wessendorf wrote: >>> > Hi, >>> > >>> > trying to add CORS, to the Server (using RestEasy), I did this: >>> > >>> >>> https://github.com/aerogear/aerogear-unified-push-server/commit/7ccb2e7fb >>> > >>> > (and some more variations.... (e.g. see the comment out >>> > "Access-Control-Allow-Origin", where I am returning the EXACT >>> Origin)) >>> > >>> > >>> > Here is a JavaScript sample: >>> > http://jsfiddle.net/JY6n4/ >>> > >>> > >>> > Just click on the "Register a device" button, and see the errors >>> in the >>> > console.... >>> > >>> > So, I am always (with the above jsFiddle) getting: >>> > Origin http://fiddle.jshell.net <http://fiddle.jshell.net/> is not >>> > allowed by Access-Control-Allow-Origin. >>> > >>> > regardless if I use "*" or "http://fiddle.jshell.net >>> > <http://fiddle.jshell.net/>" (explicit Origin), on the >>> > "Access-Control-Allow-Origin". I always thought that "*" is a >>> > wildcard.... allowing everybody and their mother to access the >>> server. >>> > >>> > BTW. >>> > This happens with jQuery _and_ vanilla.js (XHR)..... So....... I am >>> > really overasked,... >>> > >>> > >>> > but ... is it possible that the response is correct (at least the >>> setup >>> > / my src), and that RestEasy has any problems with that stuff ?? >>> > >>> > >>> > A few more eyes are highly appreciated on this "issue". >>> > >>> > thanks!! >>> > >>> > >>> > >>> > -- >>> > Matthias Wessendorf >>> > >>> > blog: http://matthiaswessendorf.wordpress.com/ >>> > sessions: http://www.slideshare.net/mwessendorf >>> > twitter: http://twitter.com/mwessendorf >>> > >>> > >>> > >>> >>> ------------------------------------------------------------------------------ >>> > This SF.net email is sponsored by Windows: >>> > >>> > Build for Windows Store. >>> > >>> > http://p.sf.net/sfu/windows-dev2dev >>> > >>> > >>> > >>> > _______________________________________________ >>> > Resteasy-users mailing list >>> > Resteasy-users@lists.sourceforge.net >>> <mailto:Resteasy-users@lists.sourceforge.net> >>> > https://lists.sourceforge.net/lists/listinfo/resteasy-users >>> > >>> >>> -- >>> Bill Burke >>> JBoss, a division of Red Hat >>> http://bill.burkecentral.com >>> >>> >>> ------------------------------------------------------------------------------ >>> This SF.net email is sponsored by Windows: >>> >>> Build for Windows Store. >>> >>> http://p.sf.net/sfu/windows-dev2dev >>> _______________________________________________ >>> Resteasy-users mailing list >>> Resteasy-users@lists.sourceforge.net >>> <mailto:Resteasy-users@lists.sourceforge.net> >>> https://lists.sourceforge.net/lists/listinfo/resteasy-users >>> >>> >>> >>> >>> -- >>> Matthias Wessendorf >>> >>> blog: http://matthiaswessendorf.wordpress.com/ >>> sessions: http://www.slideshare.net/mwessendorf >>> twitter: http://twitter.com/mwessendorf >>> >>> >>> ------------------------------------------------------------------------------ >>> This SF.net email is sponsored by Windows: >>> >>> Build for Windows Store. >>> >>> http://p.sf.net/sfu/windows-dev2dev >>> >>> >>> >>> _______________________________________________ >>> Resteasy-users mailing list >>> Resteasy-users@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/resteasy-users >>> >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by Windows: >> >> Build for Windows Store. >> >> http://p.sf.net/sfu/windows-dev2dev >> _______________________________________________ >> Resteasy-users mailing list >> Resteasy-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/resteasy-users >> > ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Resteasy-users mailing list Resteasy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/resteasy-users