Get favicon not found "GET /favicon.ico HTTP/1.1" 404 Not Found #11385
-
First Check
Commit to Help
Example Codefrom fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI(title="Quiz AI App Backend", version="0.0.1",docs_url='/')
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_methods=["*"],
allow_headers=["*"],
allow_credentials=True,
)
@app.get("/ping")
def health_check():
"""Health check."""
return {"message": "Hello I am working!"} DescriptionWhen I am using this simple endpoint I am get this in logs Operating SystemLinux Operating System DetailsDistributor ID: Zorin FastAPI Version0.110.0 Pydantic Version2.6.4 Python VersionPython 3.10.14 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
This is your browser automatically making a request looking for a favicon to put on the tab (and other places) You can just ignore them if you don't care about the favicon. If you do care you host a file at that path with that name using https://fastapi.tiangolo.com/tutorial/static-files/ or set https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel#icon in your html to tell the browser to check somewhere else. |
Beta Was this translation helpful? Give feedback.
-
Thanks @YuriiMotov for the solution. For anyone using this approach remember to import from FileResponse as shown below: from fastapi.responses import FileResponse |
Beta Was this translation helpful? Give feedback.
This is your browser automatically making a request looking for a favicon to put on the tab (and other places)
You can just ignore them if you don't care about the favicon.
If you do care you host a file at that path with that name using https://fastapi.tiangolo.com/tutorial/static-files/ or set https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel#icon in your html to tell the browser to check somewhere else.