Browse Source

chore: optimize asset caching, clean up dev UI components, update auth token retrieval, and externalize docker configurations

front-test-2
mortezaei 4 weeks ago
parent
commit
49b20d1b8b
  1. 11
      next.config.ts
  2. 6
      src/app/layout.tsx
  3. 6
      src/lib/http.ts

11
next.config.ts

@ -80,6 +80,17 @@ const nextConfig: NextConfig = {
}, },
], ],
}, },
{
// Images and icons are not content-hashed, so revalidate instead of
// pinning them for a year.
source: "/assets/:path*",
headers: [
{
key: "Cache-Control",
value: "public, max-age=86400, stale-while-revalidate=604800",
},
],
},
]; ];
}, },
}; };

6
src/app/layout.tsx

@ -171,14 +171,14 @@ export default function RootLayout({
</head> </head>
<body className={`${faminela.variable} ${amiri.variable}`} suppressHydrationWarning> <body className={`${faminela.variable} ${amiri.variable}`} suppressHydrationWarning>
<Providers> <Providers>
{isDevelopment ? (
<div className="fixed top-3 left-3 z-[9999] pointer-events-auto"> <div className="fixed top-3 left-3 z-[9999] pointer-events-auto">
<TokenSwitcher /> <TokenSwitcher />
</div> </div>
) : null}
<div className="app-shell">{children}</div> <div className="app-shell">{children}</div>
</Providers> </Providers>
{process.env.NODE_ENV === "development" ? (
<DevClickToComponent />
) : null}
{isDevelopment ? <DevClickToComponent /> : null}
</body> </body>
</html> </html>
); );

6
src/lib/http.ts

@ -64,7 +64,7 @@ export const http = axios.create({
withCredentials: true, withCredentials: true,
}); });
http.interceptors.request.use(async (config) => {
http.interceptors.request.use((config) => {
if (shouldUseProxy() && config.url && !isAbsoluteUrl(config.url)) { if (shouldUseProxy() && config.url && !isAbsoluteUrl(config.url)) {
config.params = withProxyPathParam(config.params, config.url); config.params = withProxyPathParam(config.params, config.url);
config.url = ""; config.url = "";
@ -84,10 +84,8 @@ http.interceptors.request.use(async (config) => {
config.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"; config.headers["Cache-Control"] = "no-cache, no-store, must-revalidate";
config.headers["Pragma"] = "no-cache"; config.headers["Pragma"] = "no-cache";
// Wait for a pending Flutter token injection rather than firing the request
// unauthenticated (or, as before, with a hardcoded test token).
const token = const token =
(await authBridge.waitForToken()) ??
authBridge.getToken() ??
getClientCookie("HABIB_TOKEN") ?? getClientCookie("HABIB_TOKEN") ??
getClientCookie("habib_token"); getClientCookie("habib_token");

Loading…
Cancel
Save