swagger-api / swagger-api/swagger-ui

Swagger UI page resources not loading on Safari over http on localhost; page relative links (js, css) assumed to be over https - by Safari Only

Open
#7,785 10 comments 18 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Environment:

  • OS: macOS
  • Browser: safari
  • Version: 15.1
  • Method of installation: npm
  • Swagger-UI version: swagger-ui-express: ^4.1.6,
  • OpenAPI version: 3.0.0

Description

When I run swagger UI from an express server, in Safari on a Mac over http on localhost, using

  app.use("/rest-docs", swaggerUi.serve, swaggerUi.setup(openApi.get()))  

the Swagger UI page html loads, but its relatively linked resources (js, css) don't load.

For each linked file, there is an error like the error below, each assuming that the linked resource should be served over https (even though the Swagger UI html is being served over http, as expected):

Failed to load resource: An SSL error has occurred and a secure connection to the server cannot be made. https://localhost:2020/rest-docs/swagger-ui-bundle.js

This problem occurs on Safari, but does not occur on Chrome or FireFox.

Its unclear to me whether this is a Safari issue, a Swagger issue, or something else. (Since v9, Safari handles mixed http / https content differently, which may (?) be related...)

In Safari, I have:

  • Deleted the HSTS.plist file
  • Cleared cache & history
  • Disabled resource cacheing
  • Restarted browser and computer
  • Other recommendations posted here.

Could Swagger be forcing use of https for relatively-linked resources of the Swagger UI html, served over http for Safari?

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

Reproduce the issue with the shown Express setup in Safari 15.1 on macOS, serving Swagger UI over HTTP on localhost, and compare it with Chrome or Firefox. Inspect the generated page's relative JavaScript and CSS resource URLs; done means all referenced resources load over HTTP without Safari attempting HTTPS.

Written by the indexing model from the issue text.

Assessment

Tech stack
express, javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.