From 9cc8e573ec4b6e0a9649a8dde18cc2699dc73c89 Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Tue, 14 Apr 2026 14:48:02 +0200 Subject: [PATCH] fix(next-config): merge custom rewrites properly instead of overriding --- packages/next-config/index.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/packages/next-config/index.js b/packages/next-config/index.js index 56aaa9b..84bc731 100644 --- a/packages/next-config/index.js +++ b/packages/next-config/index.js @@ -8,11 +8,6 @@ import path from "node:path"; export const baseNextConfig = { output: "standalone", turbopack: {}, - experimental: { - serverActions: { - allowedOrigins: ["*.klz-cables.com", "*.branch.klz-cables.com", "localhost:3000", "*.mintel.me"], - }, - }, images: { dangerouslyAllowSVG: true, contentDispositionType: "attachment", @@ -58,6 +53,27 @@ const withMintelConfig = (config) => { let nextConfig = { ...baseNextConfig, ...config }; + // Explicitly merge rewrites + nextConfig.rewrites = async () => { + const defaultRewrites = await baseNextConfig.rewrites(); + let customRewrites = {}; + if (typeof config.rewrites === 'function') { + customRewrites = await config.rewrites(); + } else if (Array.isArray(config.rewrites)) { + customRewrites = config.rewrites; + } + + if (Array.isArray(customRewrites)) { + return [...defaultRewrites, ...customRewrites]; + } + + return { + beforeFiles: [...(customRewrites.beforeFiles || []), ...defaultRewrites], + afterFiles: customRewrites.afterFiles || [], + fallback: customRewrites.fallback || [], + }; + }; + if (hasI18nConfig) { const withNextIntl = createNextIntlPlugin(); nextConfig = withNextIntl(nextConfig); @@ -76,3 +92,4 @@ const withMintelConfig = (config) => { }; export default withMintelConfig; +