apiflask icon indicating copy to clipboard operation
apiflask copied to clipboard

Wrong URL schema on swagger page

Open 0x0400 opened this issue 10 months ago • 2 comments
trafficstars

Description of the issue

The service is deployed with gunicorn + Nginx. The actual URL schema is https, but the server URL schema on Swagger page is http. When we click the Try it out button, the request will be blocked by the browser. image

We can use the / as the default server URL to fix the issue. https://swagger.io/docs/specification/v3_0/api-host-and-base-path/

Environment:

  • Python version: 3.12.8
  • Flask version: 3.0.3
  • APIFlask version: 2.2.1

0x0400 avatar Dec 27 '24 03:12 0x0400

Configure it with the below example code.

app.servers = [
    {
        'url': 'https://api.example.com'
    }
]

See more details in Configuration.

uncle-lv avatar Dec 27 '24 14:12 uncle-lv

Is the Nginx proxy configuration incorrect? Could you share the proxy-related config section?

Possible useful info:

  • https://docs.nginx.com/nginx/admin-guide/security-controls/securing-http-traffic-upstream/#complete-example
  • https://serverfault.com/questions/372886/prevent-nginx-from-redirecting-traffic-from-https-to-http-when-used-as-a-reverse

greyli avatar Feb 16 '25 10:02 greyli