'Python FastAPI : Invalid HTTP request received

We are started getting below warning after adding HTTPSRedirectMiddleware in fastapi

We are trying to redirect all http requests to https.

am I missing something ? I have added below middle-ware in my app HTTPSRedirectMiddleware

"lvl":"WARN","msg":"Invalid HTTP request received.\nTraceback (most recent call last):\n File "/app/.venv/lib/python3.8/site-packages/uvicorn/protocols/http/httptools_impl.py", line 131, in data_received\n self.parser.feed_data(data)\n File "httptools/parser/parser.pyx", line 212, in httptools.parser.parser.HttpParser.feed_data\nhttptools.parser.errors.HttpParserInvalidMethodError: Invalid method encountered","pid":19,"tid":139754169841472,"tsi":"2022-05-12T07:40:24.369441Z"}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source