feat: platform-aware storefront routing and billing improvements
Overhaul storefront URL routing to be platform-aware:
- Dev: /platforms/{code}/storefront/{store_code}/
- Prod: subdomain.platform.lu/ (internally rewritten to /storefront/)
- Add subdomain detection in PlatformContextMiddleware
- Add /storefront/ path rewrite for prod mode (subdomain/custom domain)
- Remove all silent platform fallbacks (platform_id=1)
- Add require_platform dependency for clean endpoint validation
- Update route registration, templates, module definitions, base_url calc
- Update StoreContextMiddleware for /storefront/ path detection
- Remove /stores/ from FrontendDetector STOREFRONT_PATH_PREFIXES
Billing service improvements:
- Add store_platform_sync_service to keep store_platforms in sync
- Make tier lookups platform-aware across billing services
- Add tiers for all platforms in seed data
- Add demo subscriptions to seed
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -91,8 +91,9 @@ async def homepage(
|
||||
if store:
|
||||
logger.debug(f"[HOMEPAGE] Store detected: {store.subdomain}")
|
||||
|
||||
# Get platform_id (use platform from context or default to 1 for OMS)
|
||||
platform_id = platform.id if platform else 1
|
||||
if not platform:
|
||||
raise HTTPException(status_code=400, detail="Platform context required")
|
||||
platform_id = platform.id
|
||||
|
||||
# Try to find store landing page (slug='landing' or 'home')
|
||||
landing_page = content_page_service.get_page_for_store(
|
||||
@@ -133,21 +134,19 @@ async def homepage(
|
||||
else "unknown"
|
||||
)
|
||||
|
||||
if access_method == "path":
|
||||
full_prefix = (
|
||||
store_context.get("full_prefix", "/store/")
|
||||
if store_context
|
||||
else "/store/"
|
||||
)
|
||||
if access_method == "path" and platform:
|
||||
return RedirectResponse(
|
||||
url=f"{full_prefix}{store.subdomain}/storefront/", status_code=302
|
||||
url=f"/platforms/{platform.code}/storefront/{store.store_code}/",
|
||||
status_code=302,
|
||||
)
|
||||
# Domain/subdomain - redirect to /storefront/
|
||||
return RedirectResponse(url="/storefront/", status_code=302)
|
||||
# Domain/subdomain - root is storefront
|
||||
return RedirectResponse(url="/", status_code=302)
|
||||
|
||||
# Scenario 2: Platform marketing site (no store)
|
||||
# Load platform homepage from CMS (slug='home')
|
||||
platform_id = platform.id if platform else 1
|
||||
if not platform:
|
||||
raise HTTPException(status_code=400, detail="Platform context required")
|
||||
platform_id = platform.id
|
||||
|
||||
cms_homepage = content_page_service.get_platform_page(
|
||||
db, platform_id=platform_id, slug="home", include_unpublished=False
|
||||
@@ -227,9 +226,10 @@ async def content_page(
|
||||
This is a catch-all route for dynamic content pages managed via the admin CMS.
|
||||
Platform pages have store_id=None and is_platform_page=True.
|
||||
"""
|
||||
# Get platform from middleware (default to OMS platform_id=1)
|
||||
platform = getattr(request.state, "platform", None)
|
||||
platform_id = platform.id if platform else 1
|
||||
if not platform:
|
||||
raise HTTPException(status_code=400, detail="Platform context required")
|
||||
platform_id = platform.id
|
||||
|
||||
# Load platform marketing page from database
|
||||
page = content_page_service.get_platform_page(
|
||||
|
||||
Reference in New Issue
Block a user