Skip to content
Merged
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
2 changes: 1 addition & 1 deletion apps/kitchen_mate/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ ENV STORAGE_LOCAL_PATH=/data/uploads
EXPOSE $PORT

# Run migrations and start the application (shell form to expand $PORT)
CMD uv run alembic upgrade head && uv run uvicorn kitchen_mate.main:app --host 0.0.0.0 --port $PORT
CMD uv run alembic upgrade head && uv run uvicorn kitchen_mate.main:app --host 0.0.0.0 --port $PORT --proxy-headers --forwarded-allow-ips="*"
3 changes: 0 additions & 3 deletions apps/kitchen_mate/src/kitchen_mate/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ class Settings(BaseSettings):
# CORS configuration
cors_origins: str = "http://localhost:5173"

# Base URL for constructing shareable links
app_base_url: str = "http://localhost:5173"

# Database configuration
cache_db_path: str = "kitchenmate.db"
cache_enabled: bool = True
Expand Down
9 changes: 5 additions & 4 deletions apps/kitchen_mate/src/kitchen_mate/routes/sharing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

from typing import Annotated

from fastapi import APIRouter, Depends, HTTPException
from fastapi import APIRouter, Depends, HTTPException, Request

from kitchen_mate.auth import User, get_user
from kitchen_mate.config import Settings, get_settings
from kitchen_mate.database.repositories import (
create_or_get_share,
get_share_by_token,
Expand All @@ -17,22 +16,24 @@
)
from kitchen_mate.schemas import CreateShareResponse, SaveSharedRecipeResponse, SharedRecipeResponse


router = APIRouter()


@router.post("/me/recipes/{recipe_id}/share", response_model=CreateShareResponse)
async def create_share(
recipe_id: str,
request: Request,
user: Annotated[User, Depends(get_user)],
settings: Annotated[Settings, Depends(get_settings)],
) -> CreateShareResponse:
"""Generate a shareable link for a recipe."""
try:
share = await create_or_get_share(user.id, recipe_id)
except ValueError:
raise HTTPException(status_code=404, detail="Recipe not found")

share_url = f"{settings.app_base_url}/shared/{share.share_token}"
base_url = f"{request.url.scheme}://{request.url.netloc}"
share_url = f"{base_url}/shared/{share.share_token}"
return CreateShareResponse(
share_token=share.share_token,
share_url=share_url,
Expand Down
Loading