[Python] FastAPI (Python) Why I get "Unsupported upgrade request." with POST request?

Discussão em 'Python' iniciado por Stack, Fevereiro 5, 2025.

  1. Stack

    Stack Membro Participativo

    I have similar apps on Flask and FastAPI. When I do this curl requests with Flask, that is all right:

    Without TLS:

    curl -X POST -H "Content-Type: application/json" -d '{"method": "account.auth"}' http://X.X.X.X:5050/

    {"error":0,"result":{"token":"XXX"}}


    With TLS:

    curl -X POST -H "Content-Type: application/json" -d '{"method": "account.auth"}' https://example.com:8443/api/

    {"error":0,"result":{"token":"XXX"}}


    !!! But with FastAPI I get another result:

    Without TLS:

    curl -X POST -H "Content-Type: application/json" -d '{"method": "account.auth"}' http://X.X.X.X:5050/

    {"error":0,"result":{"token":"XXX"}}


    With TLS:

    curl -X POST -H "Content-Type: application/json" -d '{"method": "account.auth"}' https://example.com:8443/api/

    Unsupported upgrade request.


    How to fix problem with "Unsupported upgrade request."? And what is it? Flask are working with it normally.

    Continue reading...

Compartilhe esta Página