I have been trying to enable CORS on a jetty server using overrideDescriptor tag in context.xml. The override-web.xml is as follows:
<web-app>
<filter> <filter-name>cross-origin</filter-name>
<filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
<init-param>
<param-name>allowedOrigins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>allowedMethods</param-name>
<param-value>GET,POST,DELETE,PUT,HEAD</param-value>
</init-param>
<init-param>
<param-name>allowedHeaders</param-name>
<param-value>origin, content-type, accept</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>cross-origin</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
I have added the following line in my jetty-context.xml
<Set name="overrideDescriptor">/path/to/override-web.xm</Set>
When Jetty is started i can see in the Debug logs that CrossOriginFilter is initialised properly. But i am still getting No 'Access-Control-Allow-Origin' header is present on the requested resource. I don't know why is this happening.
Can someone suggest the reason or how to fix this? Can the original web.xml interfere with the overrideDescriptor?
Any help is appreciated.
Thanks,
Harsh