You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/next/src/build/analysis/get-page-static-info.ts
+10-1Lines changed: 10 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -392,7 +392,16 @@ function validateMiddlewareProxyExports({
392
392
393
393
if(!hasValidExport){
394
394
thrownewError(
395
-
`The ${fileName==='proxy' ? 'Proxy' : 'Middleware'} file "./${basename(pageFilePath)}" must export a function named \`${fileName}\` or a default function.`
395
+
`The ${fileName==='proxy' ? 'Proxy' : 'Middleware'} file "./${basename(pageFilePath)}" must export a function named \`${fileName}\` or a default function.\n`+
396
+
`This function is what Next.js runs for every request handled by this ${fileName==='proxy' ? 'proxy (previously called middleware)' : 'middleware'}.\n\n`+
397
+
`Why this happens:\n`+
398
+
`- The file exists but doesn't export a function.\n`+
399
+
`- The export is not a function (e.g., an object or constant).\n`+
400
+
`- There's a syntax error preventing the export from being recognized.\n\n`+
401
+
`To fix it:\n`+
402
+
`- Check your "${fileName}" file.\n`+
403
+
`- Ensure it has either a default or "${fileName}" function export.\n`+
`The ${isProxy ? 'Proxy' : 'Middleware'} file "${relativeFilePath.startsWith('.') ? relativeFilePath : `./${relativeFilePath}`}" must export a function named \`${isProxy ? 'proxy' : 'middleware'}\` or a default function.`
25
+
`The ${isProxy ? 'Proxy' : 'Middleware'} file "${relativeFilePath.startsWith('.') ? relativeFilePath : `./${relativeFilePath}`}" must export a function named \`${isProxy ? 'proxy' : 'middleware'}\` or a default function.
26
+
This function is what Next.js runs for every request handled by this ${fileName==='proxy' ? 'proxy (previously called middleware)' : 'middleware'}.
27
+
28
+
Why this happens:
29
+
- The file exists but doesn't export a function.
30
+
- The export is not a function (e.g., an object or constant).
31
+
- There's a syntax error preventing the export from being recognized.
32
+
33
+
To fix it:
34
+
- Check your "${fileName}" file.
35
+
- Ensure it has either a default or "${fileName}" function export.
0 commit comments