Duffer Derek

Current Path : /var/www/sitesecurity.bitkit.dk/httpdocs/
Upload File :
Current File : /var/www/sitesecurity.bitkit.dk/httpdocs/next.config.ts

import type { NextConfig } from "next";
import { ALLOWED_IMAGE_HOSTNAMES, ALLOWED_DEV_ORIGINS } from "./src/config/domains";

// Module exports for development origins
export const allowedDevOrigins = ALLOWED_DEV_ORIGINS;

const nextConfig: NextConfig = {
  reactStrictMode: false,
  async redirects() {
    return [
      { source: "/overview", destination: "/dashboard", permanent: false },
      { source: "/overview/:path*", destination: "/dashboard/:path*", permanent: false },
      { source: "/units", destination: "/sites", permanent: false },
      { source: "/units/:path*", destination: "/sites/:path*", permanent: false },
      { source: "/fleet", destination: "/fleet/overview", permanent: false },
      { source: "/fleet/", destination: "/fleet/overview", permanent: false },
    ];
  },
  async rewrites() {
    return [
      { source: "/dashboard", destination: "/overview" },
      { source: "/dashboard/:path*", destination: "/overview/:path*" },
      { source: "/sites", destination: "/units" },
      { source: "/sites/:path*", destination: "/units/:path*" },
    ];
  },
  images: {
    qualities: [100, 75],
    remotePatterns: ALLOWED_IMAGE_HOSTNAMES.map((hostname) => ({
      hostname,
    })),
  },
  output: "standalone",
  // Add error handling for PWA
  onDemandEntries: {
    // period (in ms) where the server will keep pages in the buffer
    maxInactiveAge: 25 * 1000,
    // number of pages that should be kept simultaneously without being disposed
    pagesBufferLength: 2,
  },
  // Add experimental features for better PWA support
  experimental: {
    // Enable better error handling
    optimizeCss: false,
  },
  async headers() {
    return [
      // Service worker files - public, max-age=0, must-revalidate
      {
        source: "/sw.js",
        headers: [
          {
            key: "Cache-Control",
            value: "public, max-age=0, must-revalidate",
          },
          {
            key: "Service-Worker-Allowed",
            value: "/",
          },
        ],
      },
      {
        source: "/firebase-messaging-sw.js",
        headers: [
          {
            key: "Cache-Control",
            value: "public, max-age=0, must-revalidate",
          },
          {
            key: "Service-Worker-Allowed",
            value: "/",
          },
        ],
      },
      // HTML and app routes - private, max-age=0, must-revalidate
      {
        source: "/:path*",
        headers: [
          {
            key: "Cross-Origin-Embedder-Policy",
            value: "credentialless",
          },
          {
            key: "Cross-Origin-Opener-Policy",
            value: "same-origin",
          },
          // Add PWA-specific headers
          {
            key: "X-Content-Type-Options",
            value: "nosniff",
          },
          {
            key: "X-Frame-Options",
            value: "DENY",
          },
          // User-specific pages cache control
          {
            key: "Cache-Control",
            value: "private, max-age=0, must-revalidate",
          },
        ],
      },
    ];
  },
};

export default nextConfig;

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists