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

@@ -7,11 +7,15 @@ Store pages for billing management:
- Invoices
"""
from fastapi import APIRouter, Depends, Path, Request
from fastapi import APIRouter, Depends, Request
from fastapi.responses import HTMLResponse
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.utils.page_context import get_store_context
from app.modules.tenancy.models import User
from app.templates_config import templates
@@ -25,11 +29,11 @@ router = APIRouter()
@router.get(
"/{store_code}/billing", response_class=HTMLResponse, include_in_schema=False
"/billing", response_class=HTMLResponse, include_in_schema=False
)
async def store_billing_page(
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),
):
@@ -44,11 +48,11 @@ async def store_billing_page(
@router.get(
"/{store_code}/invoices", response_class=HTMLResponse, include_in_schema=False
"/invoices", response_class=HTMLResponse, include_in_schema=False
)
async def store_invoices_page(
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),
):

View File

@@ -178,10 +178,11 @@
},
/**
* Get store code from URL
* Get store code from server-rendered value or URL fallback
* @returns {string|null}
*/
getStoreCode() {
if (window.STORE_CODE) return window.STORE_CODE;
const path = window.location.pathname;
const segments = path.split('/').filter(Boolean);
// Direct: /store/{code}/...

View File

@@ -139,9 +139,10 @@
},
/**
* Get store code from URL
* Get store code from server-rendered value or URL fallback
*/
getStoreCode() {
if (window.STORE_CODE) return window.STORE_CODE;
const path = window.location.pathname;
const segments = path.split('/').filter(Boolean);
if (segments[0] === 'store' && segments[1]) {