swagger-api / swagger-api/swagger-ui

swagger-ui-bundle.js GET request hangs while trying to load swagger-ui page served from flask/waitress on an IP other than localhost

Open
#5,897 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: support
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A
  • OS: Windows 10
  • Browser: Chrome 80.0.3987.122, Firefox 73.0.1
  • Method of installation: through pip install flask-swagger-ui and updating swagger-ui /dist to the latest release obtained from https://github.com/swagger-api/swagger-ui/releases/tag/v3.25.0
  • Swagger-UI version: 3.25.0
  • Swagger/OpenAPI version: Swagger 3.0, OpenAPI 3.0
Describe the bug you're encountering

When using Swagger-UI (through the flask-swagger-ui python package) and served with the flask/waitress web server, Swagger-UI works fine when using localhost but fails to load the page when using any IP/URL other than localhost. Specifically, the page hangs while trying to GET the static swagger-ui-bundle.js file (see screenshot).
The workaround was to load swagger-ui-bundle.js using unpkg instead of loading the local version. It's interesting to notice that other static files (swagger-ui-standalone-preset.js, swagger-ui.css, etc.) are loading fine.

To reproduce...
  1. Create a hello world flask project using the flask-swagger-ui python package (https://github.com/sveint/flask-swagger-ui#usage)
  2. Update the flask-swagger-ui py package /dist directory to contain the latest swagger-ui release
  3. Run the server with the real IP address of the system (not using localhost)
  4. Attempt to load the swagger-ui page using Chrome or Firefox
Expected behavior

The swagger-ui page should load just fine, like when using localhost.

Screenshots

image

Additional context or thoughts

Since this problem is specifically related to the swagger-ui-bundle.js file, and because other static files are served correctly without problems, I assume this is not an issue related to python/flask/waitress.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Swagger UI 3.25.0 page through Flask/Waitress on a non-localhost IP and observe the GET for swagger-ui-bundle.js alongside the other static assets. Compare how swagger-ui-bundle.js is loaded and served with swagger-ui-standalone-preset.js and swagger-ui.css. Done means the page loads successfully through an IP or URL in Chrome and Firefox, as it does through localhost.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.