|
|
@@ -1,36 +1,7 @@
|
|
|
-// import { parseCsv } from './helper';
|
|
|
-import type { ResponseCookie } from "next/dist/compiled/@edge-runtime/cookies";
|
|
|
|
|
|
-export const CACHE_KEY = {
|
|
|
- homeTheme: "collection-homepage",
|
|
|
- headerMenus: "header-menus",
|
|
|
- footerLink: "footer-link",
|
|
|
-};
|
|
|
-/**
|
|
|
- * Caching Tags for caching
|
|
|
- */
|
|
|
-export const TAGS = {
|
|
|
- collections: "collections",
|
|
|
- products: "products",
|
|
|
- cart: "cart",
|
|
|
- carDetail: "carDetail",
|
|
|
- address: "address",
|
|
|
- themeCustomize: "themeCustomize",
|
|
|
- defaultChannel: "channel",
|
|
|
-};
|
|
|
-
|
|
|
-/**
|
|
|
- * Checkout Caching Tags
|
|
|
- */
|
|
|
-export const CHECKOUT = {
|
|
|
- shipping: "collections",
|
|
|
- method: "products",
|
|
|
- cart: "cart",
|
|
|
-};
|
|
|
export const HIDDEN_PRODUCT_TAG = "nextjs-frontend-hidden";
|
|
|
export const DEFAULT_OPTION = "Default Title";
|
|
|
-export const BAGISTO_GRAPHQL_API_ENDPOINT = "/api/graphql";
|
|
|
-export const BAGISTO_REST_API_ENDPOINT = "/api";
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* productJsonLd constant
|
|
|
@@ -39,29 +10,14 @@ export const BASE_SCHEMA_URL = "https://schema.org";
|
|
|
export const PRODUCT_TYPE = "Product";
|
|
|
export const PRODUCT_OFFER_TYPE = "AggregateOffer";
|
|
|
|
|
|
-export const currencyCookieOptions = {
|
|
|
- path: '/', // 该cookie对那些路径有效,/ 表示所有路径
|
|
|
- maxAge: 60 * 60 * 24 * 365, // 过期时间 1年,到期后自动删除
|
|
|
- sameSite: 'lax', // 第三方网站请求你的站点时,浏览器是否携带 Cookie。
|
|
|
- secure: process.env.NODE_ENV === 'production' // true 表示这个 Cookie 是否只能通过 HTTPS 发送
|
|
|
-} satisfies Partial<ResponseCookie>;
|
|
|
|
|
|
/**
|
|
|
* cookies constant
|
|
|
*/
|
|
|
-export const BAGISTO_SESSION = process.env.BAGISTO_SESSION ?? "bagisto_session";
|
|
|
export const TOKEN = "token";
|
|
|
-export const BASE_URL = process.env.NEXTAUTH_URL;
|
|
|
+export const BASE_URL = process.env.NEXT_PUBLIC_SITE_URL;
|
|
|
export const baseUrl = process.env.NEXT_PUBLIC_BAGISTO_ENDPOINT;
|
|
|
-export const GRAPHQL_URL = `${(process.env.NEXT_PUBLIC_BAGISTO_ENDPOINT || '').replace(/\/$/, '')}${BAGISTO_GRAPHQL_API_ENDPOINT}`;
|
|
|
-export const REST_API_URL = `${(process.env.NEXT_PUBLIC_BAGISTO_ENDPOINT || '').replace(/\/$/, '')}${BAGISTO_REST_API_ENDPOINT}`;
|
|
|
-export const NEXT_AUTH_SECRET = process.env.NEXTAUTH_SECRET;
|
|
|
|
|
|
-// Server-only: Use non-public env var, fallback to public for backwards compatibility
|
|
|
-export const STOREFRONT_KEY = process.env.BAGISTO_STOREFRONT_KEY || process.env.NEXT_PUBLIC_BAGISTO_STOREFRONT_KEY || "";
|
|
|
-
|
|
|
-export const OPERATION_TO_ROUTE_MAP: Record<string, string> = {
|
|
|
-};
|
|
|
|
|
|
// -----Pagination--------//
|
|
|
export const PAGE = "page";
|
|
|
@@ -85,108 +41,6 @@ export const variants = {
|
|
|
};
|
|
|
|
|
|
|
|
|
-export const configHeader = [
|
|
|
- // Security headers for all routes
|
|
|
- {
|
|
|
- source: "/:path*",
|
|
|
- headers: [
|
|
|
- { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
|
|
|
- { key: "X-Frame-Options", value: "DENY" },
|
|
|
- { key: "X-Content-Type-Options", value: "nosniff" },
|
|
|
- { key: "X-XSS-Protection", value: "1; mode=block" },
|
|
|
- {
|
|
|
- key: "Permissions-Policy",
|
|
|
- value:
|
|
|
- "camera=(), microphone=(), geolocation=(), browsing-topics=()",
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- // Cache dynamic pages - shorter cache for frequently updated content
|
|
|
- {
|
|
|
- source: "/category/:path*",
|
|
|
- headers: [
|
|
|
- {
|
|
|
- key: "Cache-Control",
|
|
|
- value: "public, s-maxage=3600, stale-while-revalidate=86400",
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- source: "/product/:path*",
|
|
|
- headers: [
|
|
|
- {
|
|
|
- key: "Cache-Control",
|
|
|
- value: "public, s-maxage=3600, stale-while-revalidate=86400",
|
|
|
- },
|
|
|
- {
|
|
|
- key: "Vary",
|
|
|
- value: "Accept-Encoding",
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- source: "/checkout/:path*",
|
|
|
- headers: [
|
|
|
- {
|
|
|
- key: "Cache-Control",
|
|
|
- value: "private, no-cache, no-store, must-revalidate",
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- source: "/customer/:path*",
|
|
|
- headers: [
|
|
|
- {
|
|
|
- key: "Cache-Control",
|
|
|
- value: "private, no-cache, no-store, must-revalidate",
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- // Next.js static assets - long cache with immutable
|
|
|
- {
|
|
|
- source: "/_next/static/:path*",
|
|
|
- headers: [
|
|
|
- {
|
|
|
- key: "Cache-Control",
|
|
|
- value: "public, max-age=31536000, immutable",
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- source: "/_next/image/:path*",
|
|
|
- headers: [
|
|
|
- {
|
|
|
- key: "Cache-Control",
|
|
|
- value: "public, max-age=31536000, immutable",
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- // Public folder assets - long cache
|
|
|
- {
|
|
|
- source: "/image/:path*",
|
|
|
- headers: [
|
|
|
- {
|
|
|
- key: "Cache-Control",
|
|
|
- value: "public, max-age=31536000, immutable",
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- source: "/fonts/:path*",
|
|
|
- headers: [
|
|
|
- {
|
|
|
- key: "Cache-Control",
|
|
|
- value: "public, max-age=31536000, immutable",
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
-]
|
|
|
-
|
|
|
-
|
|
|
-export const imageProtocol = (process.env.NEXT_SERVER_MAGENTO_PROTOCOL ||
|
|
|
- "https") as "http" | "https";
|
|
|
-
|
|
|
-
|
|
|
|
|
|
export function getImageUrl(url?: string, baseUrl?: string, fallback: string = NOT_IMAGE) {
|
|
|
if (!url) return fallback;
|