You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by VineetKK123 <vi...@infosys.com> on 2013/06/17 06:59:09 UTC
Problem with Access-Control-Allow-Origin on Chrome
Hello All,
We are facing an issue with browser compatibility with Chrome.
Below is the architecture of our product:
Client(localhost:8080) --> ServiceMix(Camel, ActiveMQ, localhost:8181) -->
Service(Accepts RESTful POST calls, localhost:8080)
My client uses XMLHttpRequest to make a POST call to servicemix with
necessary parameters required for a particular service. Upon successful
execution, my service sends the response back in a json string format.
Now, the above flow works properly when executed using IE. When we try the
same thing with Chrome we get some error related to
“Access-Control-Allow-Origin” that says that request/response is not allowed
from localhost:8080 to localhost:8181.
Upon research I found that I need to set some request headers on camel for
allowing “Access-Control-Allow-Origin” and “Access-Control-Allow-Headers”. I
did that and now I am able to successfully hit my service, execute it but I
get the same problem while sending a response back.
One point that might help:
Currently, I have filter implemented on my service layer i.e. before coming
to the actual service end point my filter will be called. The moment I
remove my filter I do not face any problem in sending the response back.
Request to please guide/help me with this problem. Please ask me if I need
to provide more information regarding my code.
Regards,
Vineet
--
View this message in context: http://servicemix.396122.n5.nabble.com/Problem-with-Access-Control-Allow-Origin-on-Chrome-tp5717015.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: Problem with Access-Control-Allow-Origin on Chrome
Posted by Freeman Fang <fr...@gmail.com>.
Hi,
Yeah, it's risky and you only should use it in test env, and when you use browser to load some local xml file and send to the localhost you are actually in test, right? But this way generally break the CORS, this way is unsafe from very beginning.
And your server can set some http header to response message like
headers.put("Access-Control-Allow-Origin", Arrays.asList("*"));
headers.put("Access-Control-Allow-Methods", Arrays.asList("POST", "GET"));
This way works if the browser is firefox or safari, however, due to the chrome bug I mentioned before, it doesn't work for chrome.
- ------------
Freeman(Yue) Fang
Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: @Freeman小屋
On 2013-6-17, at 下午1:28, VineetKK123 wrote:
> If I use --disable-web-security my browser would be open to everyone in the
> world. Would this cause any security problems?
>
> If I add “Access-Control-Allow-Origin” and “Access-Control-Allow-Headers” in
> request headers in my "Processor" that is implemented in Camel it allows the
> request to reach the service layer. The response however faces issues. Is
> there any way that I can set such parameters while sending response.
>
>
>
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Problem-with-Access-Control-Allow-Origin-on-Chrome-tp5717015p5717017.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: Problem with Access-Control-Allow-Origin on Chrome
Posted by VineetKK123 <vi...@infosys.com>.
If I use --disable-web-security my browser would be open to everyone in the
world. Would this cause any security problems?
If I add “Access-Control-Allow-Origin” and “Access-Control-Allow-Headers” in
request headers in my "Processor" that is implemented in Camel it allows the
request to reach the service layer. The response however faces issues. Is
there any way that I can set such parameters while sending response.
--
View this message in context: http://servicemix.396122.n5.nabble.com/Problem-with-Access-Control-Allow-Origin-on-Chrome-tp5717015p5717017.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: Problem with Access-Control-Allow-Origin on Chrome
Posted by Freeman Fang <fr...@gmail.com>.
Hi,
Honestly I consider this as a chrome bug[1], workaround is to disable this check with:
google-chrome --disable-web-security
to start chrome
[1]http://code.google.com/p/chromium/issues/detail?id=67743
-------------
Freeman(Yue) Fang
Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: @Freeman小屋
On 2013-6-17, at 下午12:59, VineetKK123 wrote:
> Hello All,
>
> We are facing an issue with browser compatibility with Chrome.
> Below is the architecture of our product:
>
> Client(localhost:8080) --> ServiceMix(Camel, ActiveMQ, localhost:8181) -->
> Service(Accepts RESTful POST calls, localhost:8080)
>
> My client uses XMLHttpRequest to make a POST call to servicemix with
> necessary parameters required for a particular service. Upon successful
> execution, my service sends the response back in a json string format.
>
> Now, the above flow works properly when executed using IE. When we try the
> same thing with Chrome we get some error related to
> “Access-Control-Allow-Origin” that says that request/response is not allowed
> from localhost:8080 to localhost:8181.
>
> Upon research I found that I need to set some request headers on camel for
> allowing “Access-Control-Allow-Origin” and “Access-Control-Allow-Headers”. I
> did that and now I am able to successfully hit my service, execute it but I
> get the same problem while sending a response back.
>
> One point that might help:
> Currently, I have filter implemented on my service layer i.e. before coming
> to the actual service end point my filter will be called. The moment I
> remove my filter I do not face any problem in sending the response back.
>
> Request to please guide/help me with this problem. Please ask me if I need
> to provide more information regarding my code.
>
> Regards,
> Vineet
>
>
>
>
> --
> View this message in context: http://servicemix.396122.n5.nabble.com/Problem-with-Access-Control-Allow-Origin-on-Chrome-tp5717015.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.