Why fastapi trace http method not working?
Question:
Answers:
That’s not a problem with your code but the browser. The TRACE HTTP method has little to no support on browsers according to MDN. And since the swagger UI page for FastAPI uses the browser to make these API calls, it may not work.
However your code is working as expected. You can check that by using curl:
(venv) ➜ curl -X TRACE http://127.0.0.1:8000
"test"% (venv) ➜
From the handler method:
@app.trace("/")
def test_trace():
return "test"
That’s not a problem with your code but the browser. The TRACE HTTP method has little to no support on browsers according to MDN. And since the swagger UI page for FastAPI uses the browser to make these API calls, it may not work.
However your code is working as expected. You can check that by using curl:
(venv) ➜ curl -X TRACE http://127.0.0.1:8000
"test"% (venv) ➜
From the handler method:
@app.trace("/")
def test_trace():
return "test"