Skip to content

Conversation

@devjiwonchoi
Copy link
Member

@devjiwonchoi devjiwonchoi commented Oct 15, 2025

Improve invalid Proxy/Middleware export error message to:

> Build error occurred
Error: The file "./proxy.ts" must export a function, either as a default export or as a named "proxy" export.
This function is what Next.js runs for every request handled by this proxy (previously called middleware).

Why this happens:
- You are migrating from `middleware` to `proxy`, but haven't updated the exported function.
- The file exists but doesn't export a function.
- The export is not a function (e.g., an object or constant).
- There's a syntax error preventing the export from being recognized.

To fix it:
- Ensure this file has either a default or "proxy" function export.

Learn more: https://nextjs.org/docs/messages/middleware-to-proxy

Turbopack:

Error: Turbopack build failed with 1 errors:
./proxy.ts
Proxy is missing expected function export name
This function is what Next.js runs for every request handled by this proxy (previously called middleware).

Why this happens:
- You are migrating from `middleware` to `proxy`, but haven't updated the exported function.
- The file exists but doesn't export a function.
- The export is not a function (e.g., an object or constant).
- There's a syntax error preventing the export from being recognized.

To fix it:
- Ensure this file has either a default or "proxy" function export.

Learn more: https://nextjs.org/docs/messages/middleware-to-proxy

Closes NEXT-4741

Copy link
Member Author

devjiwonchoi commented Oct 15, 2025

@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-15-improve_proxy_invalid_export_error_message branch from 7850088 to cc9f03b Compare October 15, 2025 03:06
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-15-fix_throw_error_during_build_when_invalid_export_for_proxy branch from 68b0225 to a796ac4 Compare October 15, 2025 03:08
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-15-improve_proxy_invalid_export_error_message branch from cc9f03b to 54887d7 Compare October 15, 2025 03:08
@devjiwonchoi devjiwonchoi changed the base branch from jiwon/10-15-fix_throw_error_during_build_when_invalid_export_for_proxy to graphite-base/84887 October 15, 2025 12:57
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-15-improve_proxy_invalid_export_error_message branch from 54887d7 to 1b140cd Compare October 15, 2025 12:58
@devjiwonchoi devjiwonchoi changed the base branch from graphite-base/84887 to jiwon/10-15-fix_throw_error_during_build_when_invalid_export_for_proxy October 15, 2025 12:58
@devjiwonchoi devjiwonchoi requested review from feedthejim and icyJoseph and removed request for feedthejim and icyJoseph October 15, 2025 12:59
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-15-improve_proxy_invalid_export_error_message branch from 1b140cd to 89d1fac Compare October 15, 2025 14:06
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-15-fix_throw_error_during_build_when_invalid_export_for_proxy branch from c132d3e to 638c730 Compare October 15, 2025 14:06
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-15-improve_proxy_invalid_export_error_message branch from 89d1fac to d5a7788 Compare October 15, 2025 17:51
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-15-fix_throw_error_during_build_when_invalid_export_for_proxy branch from 638c730 to 3a0a169 Compare October 15, 2025 17:51
@devjiwonchoi devjiwonchoi changed the base branch from jiwon/10-15-fix_throw_error_during_build_when_invalid_export_for_proxy to graphite-base/84887 October 15, 2025 18:30
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-15-improve_proxy_invalid_export_error_message branch from d5a7788 to 999ed9e Compare October 16, 2025 15:57
@devjiwonchoi devjiwonchoi changed the base branch from graphite-base/84887 to jiwon/10-15-fix_throw_error_during_build_when_invalid_export_for_proxy October 16, 2025 15:57
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-15-improve_proxy_invalid_export_error_message branch from 999ed9e to 38d426a Compare October 16, 2025 16:23
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-15-fix_throw_error_during_build_when_invalid_export_for_proxy branch from 585ff17 to 172162a Compare October 16, 2025 16:23
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-15-improve_proxy_invalid_export_error_message branch from 38d426a to 3f4b756 Compare October 16, 2025 16:32
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-15-fix_throw_error_during_build_when_invalid_export_for_proxy branch from 172162a to f19dbfb Compare October 16, 2025 16:32
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-15-improve_proxy_invalid_export_error_message branch 2 times, most recently from c88daf8 to a85a3e9 Compare October 21, 2025 05:35
@mischnic mischnic force-pushed the jiwon/10-15-improve_proxy_invalid_export_error_message branch from a85a3e9 to 2918422 Compare October 21, 2025 05:38
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-15-improve_proxy_invalid_export_error_message branch from 2918422 to 5e00469 Compare October 21, 2025 05:49
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-15-improve_proxy_invalid_export_error_message branch from 0c6f0f4 to dfa6498 Compare October 21, 2025 16:55
@devjiwonchoi devjiwonchoi force-pushed the jiwon/10-15-improve_proxy_invalid_export_error_message branch from c0da357 to b293ddd Compare October 21, 2025 18:20
@devjiwonchoi devjiwonchoi merged commit 409b281 into canary Oct 21, 2025
426 of 437 checks passed
Copy link
Member Author

Merge activity

@devjiwonchoi devjiwonchoi deleted the jiwon/10-15-improve_proxy_invalid_export_error_message branch October 21, 2025 20:55
@github-actions github-actions bot added the locked label Nov 5, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

created-by: Next.js team PRs by the Next.js team. locked tests Turbopack Related to Turbopack with Next.js. type: next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants