Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Images Using Wrong Content Type #4441

Open
wants to merge 3 commits into
base: mealie-next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading