How to fix Access-Control-Allow-Origin (CORS origin) in Tomcate
CORS On Tomcat
During debugging spring source code via intellij(Editor) , sometime we get CORS issue in console .
This is a very basic configure issue in Apache tomcat , during the execute you source code .
How to fix Access-Control-Allow-Origin (CORS origin).
By use of following changes , you have to changes in the web.xml(src\main\webapp\WEB-INF) file
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>(http://localhost:8082 or * ( means any port value) </param-value>
</init-param>
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.headers</param-name>
<param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
</init-param>
<init-param>
<param-name>cors.exposed.headers</param-name>
<param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
</init-param>
<init-param>
<param-name>cors.support.credentials</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>cors.preflight.maxage</param-name>
<param-value>10</param-value>
</init-param>
</filter>
Note: More information please refer the link :
Comments
Post a Comment