Tag web

Chrome 13.x CORS (Cross-Origin Resource Sharing) issue 0

Recently, I had a problem with Chrome browser using the CORS (Cross-Origin Resource Sharing).
We are using Jetty server on the server side.
To allow cross-domain http request we using org.eclipse.jetty.servlets.CrossOriginFilter filter.
HTTP POST request led to the exclusion of Chrome 13.x browser: Origin *** is not allowed by Access-Control-Allow-Origin ….
This problem was very strange because on the other browsers (FireFox, Safari) everything works fine.

We spend a lot of time before found that Chrome send the additional parameter in the header Access-Control-Allow-Headers field: Origin.

So, to solve this issue, need to add parameter for the filter like shown below:

<filter>
	<filter-name>cross-origin</filter-name>
	<filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
	<init-param>
		<param-name>allowedHeaders</param-name>
		<param-value>X-Requested-With,Origin,Content-Type, Accept</param-value>
	</init-param>  
</filter>
<filter-mapping>
	<filter-name>cross-origin</filter-name>
	<url-pattern>/cometd/*</url-pattern>
</filter-mapping>

because default value of allowedHeaders is X-Requested-With.

<init-param>
    <param-name>allowedHeaders</param-name>
    <param-value>*</param-value>
</init-param>

Or it could be like this:


That’s it.

Good luck with CORS!

Helpful information:
http://wiki.eclipse.org/Jetty/Feature/Cross_Origin_Filter
https://developer.mozilla.org/en/HTTP_access_control
https://developer.mozilla.org/En/Server-Side_Access_Control

continue reading »

New section Sites Gallery 0

Besides programming I was always attracted by site design. So I can’t walk past a beautiful site, not to make a screenshot. For several years my collection has grown to a big size. And I decided that maybe someone will be useful to get new ideas or just inspiration for his work looking at my collection. Therefore, in my blog open new section, which will posting the sites that I find in Internet in the course of week. I will say straight away that I do not claim authorship of any of the works, all that I have not done by me. If you find your site that you would not want to see in my collection, let me know and I will immediately remove it.

continue reading »

Новый раздел Sites Gallery 0

Помимо программирования меня всегда привлекали дизайны сайтов. Поэтому я не могу пройти мимо красивого сайта, не сделав скриншот. За несколько лет моя коллекция разрослась до приличных размеров. И я решил, что возможно кому то будет полезным почерпнуть новые  идеи или просто вдохновение, для своих работ глядя на мою коллекцию. В связи с этим я в своем блоге открываю новый раздел, в котором буду выкладывать сайты, которые мне удалось найти в интернете за неделю. Скажу сразу, что я не претендую на авторство ни одной из работ, все что я выкладываю сделано не мной. Если вы обнаружите свой сайт, который вы не хотели бы видеть в коей коллекции, дайте мне знать об этом и я сразу же его удалю.

continue reading »

Denis Blog is powered by Drupal
developed by Denis Liger

Valid XHTML 1.0 Strict

Рейтинг@Mail.ru