feat: production routing support for subdomain and custom domain modes
Some checks failed
Some checks failed
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:
@@ -8,11 +8,15 @@ Store pages for core functionality:
|
||||
- Notifications
|
||||
"""
|
||||
|
||||
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
|
||||
@@ -26,11 +30,11 @@ router = APIRouter()
|
||||
|
||||
|
||||
@router.get(
|
||||
"/{store_code}/dashboard", response_class=HTMLResponse, include_in_schema=False
|
||||
"/dashboard", response_class=HTMLResponse, include_in_schema=False
|
||||
)
|
||||
async def store_dashboard_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),
|
||||
):
|
||||
@@ -55,11 +59,11 @@ async def store_dashboard_page(
|
||||
|
||||
|
||||
@router.get(
|
||||
"/{store_code}/media", response_class=HTMLResponse, include_in_schema=False
|
||||
"/media", response_class=HTMLResponse, include_in_schema=False
|
||||
)
|
||||
async def store_media_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),
|
||||
):
|
||||
@@ -79,13 +83,13 @@ async def store_media_page(
|
||||
|
||||
|
||||
@router.get(
|
||||
"/{store_code}/notifications",
|
||||
"/notifications",
|
||||
response_class=HTMLResponse,
|
||||
include_in_schema=False,
|
||||
)
|
||||
async def store_notifications_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),
|
||||
):
|
||||
|
||||
@@ -74,8 +74,9 @@ function data() {
|
||||
? segments[segments.length - 2]
|
||||
: last;
|
||||
|
||||
// Get store code from URL
|
||||
if (segments[0] === 'store' && segments[1]) {
|
||||
// Get store code from server-rendered value or URL fallback
|
||||
this.storeCode = window.STORE_CODE || null;
|
||||
if (!this.storeCode && segments[0] === 'store' && segments[1]) {
|
||||
this.storeCode = segments[1];
|
||||
}
|
||||
|
||||
@@ -281,14 +282,18 @@ function emailSettingsWarning() {
|
||||
storeCode: null,
|
||||
|
||||
async init() {
|
||||
// Get store code from URL
|
||||
const path = window.location.pathname;
|
||||
const segments = path.split('/').filter(Boolean);
|
||||
if (segments[0] === 'store' && segments[1]) {
|
||||
this.storeCode = segments[1];
|
||||
// Get store code from server-rendered value or URL fallback
|
||||
this.storeCode = window.STORE_CODE || null;
|
||||
if (!this.storeCode) {
|
||||
const path = window.location.pathname;
|
||||
const segments = path.split('/').filter(Boolean);
|
||||
if (segments[0] === 'store' && segments[1]) {
|
||||
this.storeCode = segments[1];
|
||||
}
|
||||
}
|
||||
|
||||
// Skip if we're on the settings page (to avoid showing banner on config page)
|
||||
const path = window.location.pathname;
|
||||
if (path.includes('/settings')) {
|
||||
this.loading = false;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user