Problem Building API Routes due to "Failed to collect page data" #72779
Replies: 8 comments 5 replies
-
Is the |
Beta Was this translation helpful? Give feedback.
-
env is defined help of the envalid package (https://github.com/af/envalid) in .\frontend\lib\config\config.ts. It might be the case that it does the type check and assignments at the start, but I am not deep into this package. I might add that I have removed all env vars from next.config.js and try to load all envs from config object returned by envalid.
|
Beta Was this translation helpful? Give feedback.
-
Good and valid question you are asking. I was using it since it looked easier to validate some constraints like type, range, etc. on env vars. But also open for other solutions. The logs look the same, and swcMinify is unrecognized as a key. For this build run, I have also replaced the envalid env loading with a direct string of the var in the file.
|
Beta Was this translation helpful? Give feedback.
-
Your suggestion to remove increasingly until it works sounds good, this is what I would work on if there is no obvious solution to this. This API route is only for getting Stripe events and processing them. Later in the code, we have some deps on sending email and writing entries into DB. My understanding is that in some part, Next has to make this switch/decision to decide for rendering the data over API or keeping it as it is for calls during production.
|
Beta Was this translation helpful? Give feedback.
-
Thank you, IcyJoseph for your responses. Have a productive day. |
Beta Was this translation helpful? Give feedback.
-
I have the same problem. |
Beta Was this translation helpful? Give feedback.
-
This bug is so annoying mahn |
Beta Was this translation helpful? Give feedback.
-
I'm still having this issue |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Build process fails due to API route, tries to collect page data.
My build with the latest 15.0.3 Next.js does fail because it tries to collect data for API routes, which should be handled as dynamic routes that are only for dynamic usage.
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions