You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

98 lines
2.2 KiB

import type { NextConfig } from "next";
import path from "path";
const nextConfig: NextConfig = {
output: "standalone",
allowedDevOrigins: ["192.168.1.64"],
turbopack: {},
// Compression
compress: true,
// Image optimization
images: {
formats: ["image/avif", "image/webp"],
remotePatterns: [
{
protocol: "https",
hostname: "habibapp.com",
},
],
},
// Webpack config for data-locator injection in development
webpack: (config, { dev }) => {
if (dev) {
config.module.rules.push({
test: /\.(tsx|jsx)$/,
exclude: /node_modules/,
use: [
{
loader: path.resolve(__dirname, "src/plugins/jsx-locator-loader.cjs"),
},
],
});
}
return config;
},
// Headers for caching and preload
async headers() {
return [
{
// Never cache API proxy responses – always fetch fresh from backend
source: "/api/:path*",
headers: [
{
key: "Cache-Control",
value: "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0",
},
{
key: "Pragma",
value: "no-cache",
},
{
key: "Expires",
value: "0",
},
],
},
{
// Application HTML pages – no-store to prevent HTML/shell caching in WebView
source: "/:path((?!api/|_next/|fonts/|assets/).*)",
headers: [
{
key: "Cache-Control",
value: "no-store, no-cache, must-revalidate, max-age=0",
},
{
key: "Pragma",
value: "no-cache",
},
],
},
{
source: "/fonts/:path*",
headers: [
{
key: "Cache-Control",
value: "public, max-age=31536000, immutable",
},
],
},
{
// 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",
},
],
},
];
},
};
export default nextConfig;