@djangocfg/nextjs 2.1.57 → 2.1.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/index.d.mts +6 -0
- package/dist/config/index.mjs +27 -2
- package/dist/config/index.mjs.map +1 -1
- package/dist/index.mjs +27 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/config/createNextConfig.ts +37 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/nextjs",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.59",
|
|
4
4
|
"description": "Next.js server utilities: sitemap, health, OG images, contact forms, navigation, config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nextjs",
|
|
@@ -133,9 +133,9 @@
|
|
|
133
133
|
"web-push": "^3.6.7"
|
|
134
134
|
},
|
|
135
135
|
"devDependencies": {
|
|
136
|
-
"@djangocfg/imgai": "^2.1.
|
|
137
|
-
"@djangocfg/layouts": "^2.1.
|
|
138
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
136
|
+
"@djangocfg/imgai": "^2.1.59",
|
|
137
|
+
"@djangocfg/layouts": "^2.1.59",
|
|
138
|
+
"@djangocfg/typescript-config": "^2.1.59",
|
|
139
139
|
"@types/node": "^24.7.2",
|
|
140
140
|
"@types/react": "19.2.2",
|
|
141
141
|
"@types/react-dom": "19.2.1",
|
|
@@ -74,6 +74,12 @@ export interface BaseNextConfigOptions {
|
|
|
74
74
|
experimental?: NextConfig['experimental'];
|
|
75
75
|
/** Custom env variables (merged with defaults) */
|
|
76
76
|
env?: Record<string, string | undefined>;
|
|
77
|
+
/** Additional redirects (merged with base URL normalization redirects) */
|
|
78
|
+
redirects?: NextConfig['redirects'];
|
|
79
|
+
/** Additional headers (merged with base CORS/security headers) */
|
|
80
|
+
headers?: NextConfig['headers'];
|
|
81
|
+
/** Additional rewrites */
|
|
82
|
+
rewrites?: NextConfig['rewrites'];
|
|
77
83
|
/** Override any Next.js config option */
|
|
78
84
|
[key: string]: any;
|
|
79
85
|
}
|
|
@@ -166,7 +172,37 @@ export function createBaseNextConfig(
|
|
|
166
172
|
});
|
|
167
173
|
}
|
|
168
174
|
|
|
169
|
-
|
|
175
|
+
// Merge with user-provided headers
|
|
176
|
+
const userHeaders = options.headers ? await options.headers() : [];
|
|
177
|
+
return [...headers, ...userHeaders];
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
// Rewrites (user-provided only)
|
|
181
|
+
...(options.rewrites && {
|
|
182
|
+
rewrites: options.rewrites,
|
|
183
|
+
}),
|
|
184
|
+
|
|
185
|
+
// Redirects for URL normalization
|
|
186
|
+
// Fixes "Failed to construct 'URL': Invalid URL" error with double slashes
|
|
187
|
+
async redirects() {
|
|
188
|
+
const baseRedirects = [
|
|
189
|
+
// Normalize double slashes in URL path (e.g., /foo//bar -> /foo/bar)
|
|
190
|
+
{
|
|
191
|
+
source: '/:path*(//)/:rest*',
|
|
192
|
+
destination: '/:path*/:rest*',
|
|
193
|
+
permanent: true,
|
|
194
|
+
},
|
|
195
|
+
// Handle root double slash (e.g., // -> /)
|
|
196
|
+
{
|
|
197
|
+
source: '//',
|
|
198
|
+
destination: '/',
|
|
199
|
+
permanent: true,
|
|
200
|
+
},
|
|
201
|
+
];
|
|
202
|
+
|
|
203
|
+
// Merge with user-provided redirects
|
|
204
|
+
const userRedirects = options.redirects ? await options.redirects() : [];
|
|
205
|
+
return [...baseRedirects, ...userRedirects];
|
|
170
206
|
},
|
|
171
207
|
|
|
172
208
|
// Transpile packages (merge with user-provided)
|