Skip to content
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

Docker image doesn't set charset in Content-Type #10082

Open
rick-github opened this issue Jul 12, 2024 · 0 comments · May be fixed by #10083
Open

Docker image doesn't set charset in Content-Type #10082

rick-github opened this issue Jul 12, 2024 · 0 comments · May be fixed by #10083

Comments

@rick-github
Copy link

rick-github commented Jul 12, 2024

Q&A (please complete the following information)

  • OS: Linux Mint 21.3
  • Browser: chrome, curl
  • Version: 126.0.6478.126, 7.81.0
  • Method of installation: docker pull
  • Swagger-UI version: latest
  • Swagger/OpenAPI version: latest

Content & configuration

Describe the bug you're encountering

Trying to use the docker image from https://hub.docker.com/r/swaggerapi/swagger-ui may fail because the internal nginx server is not configured to add charset: utf-8 to the Content-Type header. As a result, HTML that doesn't specify the charset (eg, <script src="localhost:8081/swagger-ui-bundle.js"></script>) will fail because the browser fetches swagger JS files but won't use them because of the embedded UTF characters.

To reproduce...

$ cat > docker-compose.yaml <<EOF
services:
  swagger-ui:
    image: swaggerapi/swagger-ui
    ports:
      - "8081:8080"
EOF
$ docker compose up -d
$ curl -s -D - -o /dev/null localhost:8081/swagger-ui-bundle.js | grep Content-Type:
Content-Type: application/javascript

Expected behavior

I expect that the Content-Type header includes charset=utf-8.

$ curl -s -D - -o /dev/null localhost:8081/swagger-ui-bundle.js | grep Content-Type:
Content-Type: application/javascript; charset=utf-8

Screenshots

Additional context or thoughts

This is more of a FYI for others in the future who are scratching their heads over why a simple swagger install doesn't seem to work. If that's you, add charset="UTF-8" to your <script> tag.

@rick-github rick-github linked a pull request Jul 12, 2024 that will close this issue
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant