swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Chrome and FireFox browers do not work

Open zcb22000 opened this issue 9 years ago • 7 comments

When reporting a bug, please provide the following details:

  • swagger-ui version: master
  • a swagger file reproducing the issue I pulled master and using dist to my project. It can't use in chrome and firefox browers ,and it is ok in IE brower. But it is support chrome and firefox browers in the overview. what is the matter? The error in chrome is : Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-C8dquOZXmULUl8DCZUsQ5fjuDP/BthM9OcPt3OM26m8='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback

zcb22000 avatar Feb 25 '17 10:02 zcb22000

Really need more details. How are you hosting your swagger-ui? Which FF and Chrome versions do you use? I just tried FF and it has no issues opening it.

webron avatar Feb 26 '17 21:02 webron

I host swagger-ui in my project which supply Restful API services. My chrome version is 55.0.2883.87, and ff is 37.0.2

zcb22000 avatar Feb 27 '17 00:02 zcb22000

It is displayed OK in chrome and ff when i create index.js file which moved js code from swagger-ui/index.html. But error message still displayed in the console of chrome brower. When I test the interface, it excute fine.

zcb22000 avatar Feb 27 '17 01:02 zcb22000

Only worked for me on firefox and with a CORS addon.

Environment: Ubuntu 16.04, firefox 54.0b2 (32-bit) and chrome Versión 57.0.2987.98 (64-bit)

guidomaiola avatar May 09 '17 19:05 guidomaiola

Why was this closed? Can someon let me know how I fix this so Swagger will work again?

avpines avatar Aug 03 '17 11:08 avpines

@aviadpines I solved it in the following way

play.filters {

  enabled += "play.filters.headers.SecurityHeadersFilter"
 
  headers {
    # The Content-Security-Policy header. If null, the header is not set.
    contentSecurityPolicy = null
  }

I don't think it's it the ideal way though

ricsirigu avatar Aug 10 '17 11:08 ricsirigu

I had the same problem. After spending a lot of hours, i found this solution - use https://github.com/iheartradio/play-swagger, and next manual works for me: https://github.com/iheartradio/play-swagger/blob/master/docs/AlternativeSetup.md For Play 2.6 i've used this dependency: "com.iheart" % "play-swagger_2.12" % "0.6.2-PLAY2.6"

Yuzvin avatar Oct 27 '17 14:10 Yuzvin