server.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. import type { ResponseCookie } from "next/dist/compiled/@edge-runtime/cookies";
  2. export const BAGISTO_GRAPHQL_API_ENDPOINT = "/api/graphql";
  3. export const BAGISTO_REST_API_ENDPOINT = "/api";
  4. export const GRAPHQL_URL = `${(process.env.NEXT_PUBLIC_BAGISTO_ENDPOINT || '').replace(/\/$/, '')}${BAGISTO_GRAPHQL_API_ENDPOINT}`;
  5. export const REST_API_URL = `${(process.env.NEXT_PUBLIC_BAGISTO_ENDPOINT || '').replace(/\/$/, '')}${BAGISTO_REST_API_ENDPOINT}`;
  6. export const currencyCookieOptions = {
  7. path: '/', // 该cookie对那些路径有效,/ 表示所有路径
  8. maxAge: 60 * 60 * 24 * 365, // 过期时间 1年,到期后自动删除
  9. sameSite: 'lax', // 第三方网站请求你的站点时,浏览器是否携带 Cookie。
  10. secure: process.env.APP_ENV !== 'development' // true 表示这个 Cookie 是否只能通过 HTTPS 发送
  11. } satisfies Partial<ResponseCookie>;
  12. export const configHeader = [
  13. // Security headers for all routes
  14. {
  15. source: "/:path*",
  16. headers: [
  17. { key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
  18. //{ key: "X-Frame-Options", value: "DENY" },
  19. { key: "X-Content-Type-Options", value: "nosniff" },
  20. // { key: "X-XSS-Protection", value: "1; mode=block" },
  21. // {
  22. // key: "Permissions-Policy",
  23. // value:
  24. // "camera=(), microphone=(), geolocation=(), browsing-topics=()",
  25. // },
  26. ],
  27. },
  28. // Cache dynamic pages - shorter cache for frequently updated content
  29. // Next.js static assets - long cache with immutable
  30. // Public folder assets - long cache
  31. ];