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
TypeError: failed to fetch
is vague and unpleasant to look at when a request fails
#4560
Comments
I hit this error during local development (i.e., had nothing to do with AWS that was reported in #3403). The underlying cause (CORS violation) is identical. It would have been helpful for "TypeError: Failed to fetch" to provide more information or at least suggest a CORS violation. Details: I set up connexion with an openapi spec that referred to http://localhost:9090/. When the development server starts, it says "Running on http://0.0.0.0:9090/". That page appears to work, but the swagger ui uses http://localhost:9090/ from the openapi spec for subsequent requests and shows |
If you run this app locally and use the OpenAPI editor to query endpoints 'GET /ping' needs to respond with CORS headers. Otherwise the swagger-editor (incorrectly) succeeds on the request but complains the request failed. See: https://editor.swagger.io/ Issue: swagger-api/swagger-ui#4560
I have faced this issue while trying to access a 302 to Azure Blob Storage. It seems to be an issue with swagger-ui, since I can download the file successfully using POSTMAN. |
@CarlosHAraujo Postman doesn't care about SOP, it's a dev tool not a browser. Since swagger-ui runs in browser it is limited to its security features like CORS policy. Just make sure the server sends correct cors headers. If you can't controll the server you probably need a middleware that will set the CORS headers accordingly. |
Content & configuration
Example Swagger/OpenAPI definition:
Current behavior
TypeError: failed to fetch
appears, giving me no clues as to what went wrong - a refused connection, in this case.To reproduce...
Steps to reproduce the behavior:
Execute
to fire an ill-fated requestDesired behavior
A styled UI element that appears instead of the regular live response display UI would more clearly indicate that no response was received at all, and displaying the browser's error reason would give me actionable information without having to open my browser console.
Additional context or thoughts
cc #3403.
The text was updated successfully, but these errors were encountered: