Skip to content

Commit

Permalink
fix: Images Using Wrong Content Type (mealie-recipes#4441)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-genson authored Oct 25, 2024
1 parent d48320f commit f7e595b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
1 change: 0 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ HEALTHCHECK CMD python $MEALIE_HOME/mealie/scripts/healthcheck.py || exit 1
# ----------------------------------
# Copy Frontend

# copying caddy into image
ENV STATIC_FILES=/spa/static
COPY --from=builder /app/dist ${STATIC_FILES}

Expand Down
11 changes: 3 additions & 8 deletions mealie/routes/media/media_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@
from mealie.schema.recipe import Recipe
from mealie.schema.recipe.recipe_timeline_events import RecipeTimelineEventOut

"""
These routes are for development only! These assets are served by Caddy when not
in development mode. If you make changes, be sure to test the production container.
"""

router = APIRouter(prefix="/recipes", include_in_schema=False)
router = APIRouter(prefix="/recipes")


class ImageType(str, Enum):
Expand All @@ -30,7 +25,7 @@ async def get_recipe_img(recipe_id: str, file_name: ImageType = ImageType.origin
recipe_image = Recipe.directory_from_id(recipe_id).joinpath("images", file_name.value)

if recipe_image.exists():
return FileResponse(recipe_image)
return FileResponse(recipe_image, media_type="image/webp")
else:
raise HTTPException(status.HTTP_404_NOT_FOUND)

Expand All @@ -48,7 +43,7 @@ async def get_recipe_timeline_event_img(
)

if timeline_event_image.exists():
return FileResponse(timeline_event_image)
return FileResponse(timeline_event_image, media_type="image/webp")
else:
raise HTTPException(status.HTTP_404_NOT_FOUND)

Expand Down
7 changes: 1 addition & 6 deletions mealie/routes/media/media_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@

from mealie.schema.user import PrivateUser

"""
These routes are for development only! These assets are served by Caddy when not
in development mode. If you make changes, be sure to test the production container.
"""

router = APIRouter(prefix="/users", include_in_schema=False)
router = APIRouter(prefix="/users")


@router.get("/{user_id}/{file_name}", response_class=FileResponse)
Expand Down

0 comments on commit f7e595b

Please sign in to comment.