fix(runtime): ถอด AppProviders/agent-native session gate ออก — prod build + static export ใช้ได้จริง
- app/root.tsx: ลบ <AppProviders>, DbSyncSetup (useDbSync/useNavigationState/queryClient) เพราะ session gate รอ /_agent-native/auth/session + /status + application-state ซึ่งตอบ 401 บน production build และ 404 บน static host → React ไม่ mount เนื้อหา, ขึ้น AppShellSkeleton + "Configuration error (2 issues)" - คงไว้: AppToolkitProvider (design system), THEME_INIT_SCRIPT, analytics, PWA, ErrorBoundary - sw.js VERSION v2.1.0 - README + DESIGN: บันทึกเหตุผลและกฎ "ห้ามใส่ AppProviders กลับ"
This commit is contained in:
1 parent
507cd44d49
commit
d1e76ab2be
4 files changed
+77
-81
No files matched your search
+6
-26
@@ -1,11 +1,7 @@
|
||||
import { configureTracking } from "@agent-native/core/client/analytics";
|
||||
import { appPath } from "@agent-native/core/client/api-path";
|
||||
import { useDbSync } from "@agent-native/core/client/hooks";
|
||||
import { createAgentNativeQueryClient } from "@agent-native/core/client/hooks";
|
||||
import { getThemeInitScript } from "@agent-native/core/client/ui";
|
||||
import { AppProviders } from "@agent-native/toolkit/app/providers";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect } from "react";
|
||||
import {
|
||||
Links,
|
||||
Meta,
|
||||
@@ -19,7 +15,6 @@ import type { LinksFunction } from "react-router";
|
||||
|
||||
import { Layout as AppLayout } from "@/components/layout/Layout";
|
||||
import { AppToolkitProvider } from "@/components/ui/toolkit-provider";
|
||||
import { useNavigationState } from "@/hooks/use-navigation-state";
|
||||
import { NearMeProvider } from "@/hooks/use-near-me";
|
||||
import { APP_NAME, APP_TITLE } from "@/lib/app-config";
|
||||
import { ContentProvider } from "@/lib/content-context";
|
||||
@@ -30,7 +25,6 @@ import { registerServiceWorker } from "@/lib/pwa";
|
||||
import { originFromRequest } from "@/lib/request-origin";
|
||||
import { ShareOriginProvider } from "@/lib/share-origin";
|
||||
import { configuredOrigin } from "@/lib/site";
|
||||
import { TAB_ID } from "@/lib/tab-id";
|
||||
|
||||
import stylesheet from "./global.css?url";
|
||||
|
||||
@@ -106,16 +100,6 @@ export function Layout({ children }: { children: React.ReactNode }) {
|
||||
);
|
||||
}
|
||||
|
||||
function DbSyncSetup() {
|
||||
const qc = useQueryClient();
|
||||
useNavigationState();
|
||||
useDbSync({
|
||||
queryClient: qc,
|
||||
ignoreSource: TAB_ID,
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
/** ลงทะเบียน service worker ครั้งเดียวฝั่ง client — ทำให้ติดตั้งเป็นแอปได้และเปิดซ้ำตอนออฟไลน์ได้ */
|
||||
function ServiceWorkerSetup() {
|
||||
useEffect(() => {
|
||||
@@ -147,7 +131,6 @@ function MotionBootstrap() {
|
||||
}
|
||||
|
||||
export default function Root() {
|
||||
const [queryClient] = useState(() => createAgentNativeQueryClient());
|
||||
const { content, localeFromUrl, shareOrigin } =
|
||||
useLoaderData<typeof loader>();
|
||||
return (
|
||||
@@ -160,14 +143,11 @@ export default function Root() {
|
||||
>
|
||||
<NearMeProvider cinemas={content.cinemas}>
|
||||
<AppToolkitProvider>
|
||||
<AppProviders queryClient={queryClient}>
|
||||
<DbSyncSetup />
|
||||
<ServiceWorkerSetup />
|
||||
<MotionBootstrap />
|
||||
<AppLayout>
|
||||
<Outlet />
|
||||
</AppLayout>
|
||||
</AppProviders>
|
||||
<ServiceWorkerSetup />
|
||||
<MotionBootstrap />
|
||||
<AppLayout>
|
||||
<Outlet />
|
||||
</AppLayout>
|
||||
</AppToolkitProvider>
|
||||
</NearMeProvider>
|
||||
</LocaleProvider>
|
||||
|
||||
Reference in new issue
Block a user