diff --git a/app/api/v1/routers/StorefrontRouter.py b/app/api/v1/routers/StorefrontRouter.py index 39213ce..fa2a0f1 100644 --- a/app/api/v1/routers/StorefrontRouter.py +++ b/app/api/v1/routers/StorefrontRouter.py @@ -3,7 +3,7 @@ @purpose Read-only public endpoints for footer info, store settings, mega menu, catalog filters, trust badges, blog posts, and product reviews — all backed by StorefrontCmsService. """ -from fastapi import APIRouter, Depends, Query +from fastapi import APIRouter, Depends, Query, Response from sqlalchemy.orm import Session from typing import Any, Dict, List, Optional @@ -18,21 +18,24 @@ router = APIRouter(prefix="/api/v1/storefront", tags=["Storefront Dynamic Servic @router.get("/footer-info") -def get_footer_info(db: Session = Depends(get_db)) -> Any: +def get_footer_info(response: Response, db: Session = Depends(get_db)) -> Any: """Returns dynamic footer contact info, social links, navigation columns, and payment icons.""" + response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" svc = StorefrontCmsService(db) return svc.get_footer_info() @router.get("/settings") -def get_storefront_settings(db: Session = Depends(get_db)) -> Any: +def get_storefront_settings(response: Response, db: Session = Depends(get_db)) -> Any: """Returns store branding settings (logo, wordmark, support phone, advance_percent, etc.).""" + response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" svc = StorefrontCmsService(db) return svc.get_settings() @router.get("/mega-menu") def get_mega_menu( + response: Response, nav_key: Optional[str] = Query(None, pattern="^(shop|deals|products)$"), db: Session = Depends(get_db), ) -> Any: @@ -41,13 +44,15 @@ def get_mega_menu( If nav_key is supplied returns single menu config. If omitted returns all three (shop, deals, products) in one payload. """ + response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" svc = StorefrontCmsService(db) return svc.get_mega_menu(nav_key) @router.get("/catalog-filters") -def get_catalog_filters(db: Session = Depends(get_db)) -> Any: +def get_catalog_filters(response: Response, db: Session = Depends(get_db)) -> Any: """Returns highlight filter tabs and price range buckets for the shop catalog page.""" + response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" svc = StorefrontCmsService(db) return svc.get_catalog_filters() @@ -112,8 +117,9 @@ def get_blog_posts() -> List[Dict[str, Any]]: @router.get("/banners") -def get_storefront_banners(db: Session = Depends(get_db)) -> List[Dict[str, Any]]: +def get_storefront_banners(response: Response, db: Session = Depends(get_db)) -> List[Dict[str, Any]]: """Returns hero banners for the storefront homepage (BUG-04 fix).""" + response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" svc = StorefrontCmsService(db) banners = svc.get_content_by_region(page="home", region="hero", content_type="hero_banner") if banners: diff --git a/app/api/v1/routers/storefront.py b/app/api/v1/routers/storefront.py index 0bd89ce..a9d743d 100644 --- a/app/api/v1/routers/storefront.py +++ b/app/api/v1/routers/storefront.py @@ -2,7 +2,7 @@ @router Public Storefront Router (Backend/app/api/v1/routers/storefront.py) @purpose Read-only public endpoints for layout widgets, reviews, and settings powered by StorefrontService. """ -from fastapi import APIRouter, Depends, Query, HTTPException, status, Request +from fastapi import APIRouter, Depends, Query, HTTPException, status, Request, Response from sqlalchemy.orm import Session, selectinload from sqlalchemy import select from typing import List, Dict, Any, Optional @@ -182,10 +182,11 @@ def live_search( @router.get("/layout/{page}") -def get_storefront_layout(page: str, region: Optional[str] = Query(None), db: Session = Depends(get_db)): +def get_storefront_layout(page: str, response: Response, region: Optional[str] = Query(None), db: Session = Depends(get_db)): """ Returns active storefront layout widgets ordered by display_order. """ + response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" service = StorefrontService(db) return service.get_layout(page, region)