feat: production routing support for subdomain and custom domain modes
Some checks failed
CI / ruff (push) Successful in 10s
CI / pytest (push) Failing after 45m18s
CI / validate (push) Successful in 24s
CI / dependency-scanning (push) Successful in 30s
CI / docs (push) Has been skipped
CI / deploy (push) Has been skipped

Double-mount store routes at /store/* and /store/{store_code}/* so the
same handlers work in dev path-based, prod path-based, prod subdomain,
and prod custom-domain modes.  Wire StorePlatform.custom_subdomain into
StoreContextMiddleware for per-platform subdomain overrides.  Add admin
custom-domain management UI, fix stale /shop/ reset link, add
/merchants/ to reserved paths, and server-render window.STORE_CODE for
JS that previously parsed the URL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-26 00:15:06 +01:00
parent 6a82d7c12d
commit ce5b54f27b
36 changed files with 822 additions and 151 deletions

View File

@@ -8,7 +8,7 @@ Store pages for:
- Program settings
- Stats dashboard
Routes follow the standard store convention: /{store_code}/loyalty/...
Routes follow the standard store convention: /loyalty/...
so they match the menu URLs in definition.py.
"""
@@ -18,7 +18,11 @@ from fastapi import APIRouter, Depends, Path, Request
from fastapi.responses import HTMLResponse, RedirectResponse
from sqlalchemy.orm import Session
from app.api.deps import get_current_store_from_cookie_or_header, get_db
from app.api.deps import (
get_current_store_from_cookie_or_header,
get_db,
get_resolved_store_code,
)
from app.modules.core.services.platform_settings_service import (
platform_settings_service,
)
@@ -86,12 +90,12 @@ def get_store_context(
@router.get(
"/{store_code}/loyalty",
"/loyalty",
response_class=RedirectResponse,
include_in_schema=False,
)
async def store_loyalty_root(
store_code: str = Path(..., description="Store code"),
store_code: str = Depends(get_resolved_store_code),
current_user: User = Depends(get_current_store_from_cookie_or_header),
):
"""
@@ -110,13 +114,13 @@ async def store_loyalty_root(
@router.get(
"/{store_code}/loyalty/terminal",
"/loyalty/terminal",
response_class=HTMLResponse,
include_in_schema=False,
)
async def store_loyalty_terminal(
request: Request,
store_code: str = Path(..., description="Store code"),
store_code: str = Depends(get_resolved_store_code),
current_user: User = Depends(get_current_store_from_cookie_or_header),
db: Session = Depends(get_db),
):
@@ -136,13 +140,13 @@ async def store_loyalty_terminal(
@router.get(
"/{store_code}/loyalty/cards",
"/loyalty/cards",
response_class=HTMLResponse,
include_in_schema=False,
)
async def store_loyalty_cards(
request: Request,
store_code: str = Path(..., description="Store code"),
store_code: str = Depends(get_resolved_store_code),
current_user: User = Depends(get_current_store_from_cookie_or_header),
db: Session = Depends(get_db),
):
@@ -157,13 +161,13 @@ async def store_loyalty_cards(
@router.get(
"/{store_code}/loyalty/cards/{card_id}",
"/loyalty/cards/{card_id}",
response_class=HTMLResponse,
include_in_schema=False,
)
async def store_loyalty_card_detail(
request: Request,
store_code: str = Path(..., description="Store code"),
store_code: str = Depends(get_resolved_store_code),
card_id: int = Path(..., description="Loyalty card ID"),
current_user: User = Depends(get_current_store_from_cookie_or_header),
db: Session = Depends(get_db),
@@ -184,13 +188,13 @@ async def store_loyalty_card_detail(
@router.get(
"/{store_code}/loyalty/stats",
"/loyalty/stats",
response_class=HTMLResponse,
include_in_schema=False,
)
async def store_loyalty_stats(
request: Request,
store_code: str = Path(..., description="Store code"),
store_code: str = Depends(get_resolved_store_code),
current_user: User = Depends(get_current_store_from_cookie_or_header),
db: Session = Depends(get_db),
):
@@ -210,13 +214,13 @@ async def store_loyalty_stats(
@router.get(
"/{store_code}/loyalty/enroll",
"/loyalty/enroll",
response_class=HTMLResponse,
include_in_schema=False,
)
async def store_loyalty_enroll(
request: Request,
store_code: str = Path(..., description="Store code"),
store_code: str = Depends(get_resolved_store_code),
current_user: User = Depends(get_current_store_from_cookie_or_header),
db: Session = Depends(get_db),
):