Hi,
I have downloaded SwaggerUI and am attempting a initial test by running from:
C:\Users\me\Downloads\swagger-ui-master\dist
I can get to the pets api-docs just fine, however when I point to the same URL above I get:
Can't read from server. It may not have the appropriate access-control-origin settings.
I've updated a simple
Rest Tutorial to jersey2/maven and Swagger annotations.
I am using Firefox and verifying via RESTClient plugin.
I can send GET and receive a valid response, so the REST api is working.
I can send a GET request to the
http://localhost:8081/TodoRest/rest/api-docs swagger api-docs via RESTClient and I get swagger/json back
{"apiVersion":"1.0.0","swaggerVersion":"1.2","apis":[{"path":"/todo","description":"Operations about Todos"}]}I captured the communication with fiddler, note the Origin: null the null is an ascii string "null"
GET http://localhost:8081/TodoRest/rest/api-docs HTTP/1.1
Host: localhost:8081
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
Accept: application/json
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Origin: null
Connection: keep-alive
HTTP/1.1 403 Forbidden
Server: Apache-Coyote/1.1
Content-Type: text/plain
Content-Length: 0
Date: Tue, 22 Jul 2014 18:09:15 GMT
I did a bunch of googling and found that I should be able to turn on a tomcat filter in the
\tomcat\apache-tomcat-7.0.54\conf\web.xml, but it doesn't seem to work.
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<!-- init-param>
<param-name>cors.allowed.origins</param-name>
<!-- tried several different param-value combinations -->
<param-value>"null"</param-value> <!-- tried null with quotes -->
<param-value>*</param-value> <!-- tried * -->
<param-value>*, null</param-value> <!-- tried *, null -->
<param-value>null</param-value> <!-- tried null -->
</init-param -->
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
I bumbed the logging.properties
org.apache.catalina.filters.CorsFilter.level = FINEST
this shows the following at the Tomcat console
FINE: Invalid CORS request; Origin=null;Method=GET
So, I assume I have configured something incorrectly, but I can't figure out what it is.
If you can tell me how to handle Origin=null either in tomcat or via swagger that would be great!
Thanks,
Tim