Set CORS header in Tomcat -


i had static website hosted tomcat.

how set header site like:access-control-allow-origin: *

they static file, not servlet application.

if it's static site, starting tomcat 7.0.41, can control cors behavior via built-in filter.

pretty thing have edit global web.xml in catalina_home/conf , add filter definition:

      <!-- ================== built in filter definitions ===================== -->        ...       <filter>        <filter-name>corsfilter</filter-name>        <filter-class>org.apache.catalina.filters.corsfilter</filter-class>      </filter>      <filter-mapping>        <filter-name>corsfilter</filter-name>        <url-pattern>/*</url-pattern>      </filter-mapping>      <!-- ==================== built in filter mappings ====================== -->  

be aware, though, firefox not access-control-allow-origin: * , requests credentials (cookies): when responding credentialed request, server must specify domain, , cannot use wild carding.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -