fix(routing): fix store login 404 caused by CMS catch-all route priority
The CMS catch-all route /{store_code}/{slug} was registered before tenancy's
/{store_code}/login because modules are discovered alphabetically (cms before
tenancy). Also fix login.js store code extraction for /platforms/{code}/store/...
URL pattern.
- Add ROUTE_CONFIG priority=100 to CMS store pages so catch-all registers last
- Sort get_store_page_routes() by priority (matching other route getters)
- Use indexOf('store') in login.js to support platform-prefixed URLs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,11 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
# Route configuration - high priority so catch-all is registered last
|
||||
ROUTE_CONFIG = {
|
||||
"priority": 100,
|
||||
}
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# HELPER: Build Store Dashboard Context
|
||||
@@ -176,11 +181,13 @@ async def store_content_page(
|
||||
)
|
||||
|
||||
store = getattr(request.state, "store", None)
|
||||
platform = getattr(request.state, "platform", None)
|
||||
store_id = store.id if store else None
|
||||
platform_id = platform.id if platform else 1
|
||||
|
||||
# Load content page from database (store override → platform default)
|
||||
page = content_page_service.get_page_for_store(
|
||||
db, slug=slug, store_id=store_id, include_unpublished=False
|
||||
db, platform_id=platform_id, slug=slug, store_id=store_id, include_unpublished=False
|
||||
)
|
||||
|
||||
if not page:
|
||||
|
||||
@@ -286,8 +286,15 @@ def get_page_routes() -> list[RouteInfo]:
|
||||
|
||||
|
||||
def get_store_page_routes() -> list[RouteInfo]:
|
||||
"""Get store page routes from modules."""
|
||||
return [r for r in discover_module_routes() if r.route_type == "pages" and r.frontend == "store"]
|
||||
"""
|
||||
Get store page routes from modules, sorted by priority.
|
||||
|
||||
Returns routes sorted by priority (lower first, higher last).
|
||||
This ensures catch-all routes (priority 100+) are registered after
|
||||
specific routes.
|
||||
"""
|
||||
routes = [r for r in discover_module_routes() if r.route_type == "pages" and r.frontend == "store"]
|
||||
return sorted(routes, key=lambda r: r.priority)
|
||||
|
||||
|
||||
def get_admin_page_routes() -> list[RouteInfo]:
|
||||
|
||||
@@ -39,9 +39,11 @@ function storeLogin() {
|
||||
storeLoginLog.debug('Dark mode:', this.dark);
|
||||
|
||||
// Get store code from URL path
|
||||
// Supports both /store/{code}/login and /platforms/{platform}/store/{code}/login
|
||||
const pathSegments = window.location.pathname.split('/').filter(Boolean);
|
||||
if (pathSegments[0] === 'store' && pathSegments[1]) {
|
||||
this.storeCode = pathSegments[1];
|
||||
const storeIndex = pathSegments.indexOf('store');
|
||||
if (storeIndex !== -1 && pathSegments[storeIndex + 1]) {
|
||||
this.storeCode = pathSegments[storeIndex + 1];
|
||||
storeLoginLog.debug('Store code from URL:', this.storeCode);
|
||||
await this.loadStore();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user