New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't read from server. It may not have the appropriate access-control-origin settings. ? #146
Comments
Your server is not allowing CORS requests: curl -i "http://swagger-espn.mobovivo.com/api-docs.json"
HTTP/1.1 200 OK
Date: Tue, 12 Feb 2013 05:14:27 GMT
Server: Apache/2.2.20 (Ubuntu)
Last-Modified: Tue, 12 Feb 2013 04:02:39 GMT
ETag: "738ec-154-4d57f18baad57"
Accept-Ranges: bytes
Content-Length: 340
Content-Type: application/json In order to run the swagger-ui from a host other than mobovivo.com, you'll have to return the proper header values for curl -i "http://api.wordnik.com/v4/resources.json"
HTTP/1.1 200 OK
Access-Control-Allow-Headers: Origin, X-Atmosphere-tracking-id, X-Atmosphere-Framework, X-Cache-Date, Content-Type, X-Atmosphere-Transport, *
Access-Control-Allow-Methods: POST, GET, OPTIONS , PUT
Access-Control-Allow-Origin: *
Access-Control-Request-Headers: Origin, X-Atmosphere-tracking-id, X-Atmosphere-Framework, X-Cache-Date, Content-Type, X-Atmosphere-Transport, *
Content-Type: application/json
Date: Tue, 12 Feb 2013 05:14:27 GMT
Content-Length: 319
Connection: keep-alive |
Thanks, I enabled CORS and it works! 👍 |
great news |
Could you please tell me how? I have a pretty standard webapp running on tomcat (6/7). I always get that message and I do not really understand what I have to do. HTTP/1.1 200 OK {"apiVersion":"0.1-ALPHA","swaggerVersion":"1.0","basePath":"http://localhost:9999/","apis":[{"path":"/api-docs/rest/api/order"}]} |
Just got mine working... Awesome! |
@toshim45 - what's the output you're getting when running:
|
hi @webron $ curl -i "http://localhost:8080/pena-im/api-docs" HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Access-Control-Allow-Origin: * Access-Control-Allow-Methods: POST, GET, DELETE, PUT, OPTIONS Access-Control-Allow-Headers: Content-Type, api_key, Authorization, x-requested-with, Total-Count, Total-Pages, Error-Message Access-Control-Max-Age: 1800 Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked Date: Tue, 19 Aug 2014 19:47:47 GMT {"apiVersion":"1.0","swaggerVersion":"1.2","apis":[{"path":"/default/compose-controller","description":"Compose Controller"},{"path":"/default/home-controller","description":"Home Controller"},{"path":"/default/inbox-controller","description":"Inbox Controller"}],"info":{"title":"default Title","description":"Api Description","termsOfServiceUrl":"Api terms of service","contact":"Contact Email","license":"Licence Type","licenseUrl":"License URL"}} |
sorry my mistake, my configuration is wrong in index.html :) it should be ip address, not localhost. |
You rock man! |
Hi Guyz, I just started using swagger, can you help me understand how do I use it to document my REST API's? Thanks in advance!! |
I got it downloaded from github , but now how to initiate to make it work for my own API's instead of petstore already existing one |
@jhambj - Please send a post to https://groups.google.com/forum/#!forum/swagger-swaggersocket with the details of your application, and I'll help you from there. |
just doing that but even I am not sure what all details are needed though leaving a post there.Thank you so much. |
Hi, I could solve this issue on Tomcat server, but it remains a problem on websphere application server profile as a server. Do you have any way to fix this? Many thx :-) |
Not sure why websphere would be any different. Enabling CORS is normally done at the application level, though tomcat has its own filter you may have used. Just enable it on websphere and you should be done. |
Why we need to accept CORS for fetching json file? |
You don't need CORS for a GET. Swagger-js (the underlying library for the UI) does not differentiate in the request process and therefore sends a preflight request. |
where do you put the bit of code in to allow CORS? Thanks! |
@icwatk - that depends on how you serve your swagger.json and API. no single answer to it. |
I would recommend in the error message including a link to a resource or two to help users who hit this issue more quickly solve the issue they are seeing. |
@kkirsche - while I agree that when it comes to user experience it would be better, there's also this - https://github.com/swagger-api/swagger-ui#or-how-to-deal-with-cant-read-from-server-it-may-not-have-the-appropriate-access-control-origin-settings. It's right there in the README of this project. |
Which doesn't help to individuals running this for a company. The readme only is helpful to the deployer |
Hi, The server returns the following message: when trying to fetch swagger data in html format. The API URL is: http://localhost:8080/config/config/swagger.json index.html- web.xml
Could you please help to fix the issue? Thanks in advance |
it's very easy.What you should do is change "localhost" to "127.0.0.1"!Then you will success. |
hey i'm working with swagger hub but when i click on try it out for an endpoint i got this error ,could you help me please access-control-allow-credentials: true access-control-allow-headers: X-Requested-With,Content-Type,Accept,Origin access-control-allow-methods: * access-control-allow-origin: * cache-control: no-cache content-length: 0 content-type: application/octet-stream date: Wed,28 Apr 2021 17:25:24 GMT etag: W/"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk" expires: -1 server: Jetty(9.4.29.v20200521) status: 404 Not Found x-firefox-spdy: h2 x-powered-by: Express,Phusion Passenger(R) 6.0.8 |
Hi, I can access to swagger doc from localhost. However, when host the app within Docker container and do a port forward from localhost to the container, I got the same message Can someone suggest solution please? Thanks |
Hi,
The server returns the following message:
"Can't read from server. It may not have the appropriate access-control-origin settings."
The API URL is: http://swagger-espn.mobovivo.com/api-docs.json
Could you please help to fix the issue?
Thanks in advance
SPEC FILE
The text was updated successfully, but these errors were encountered: