[Nextjs 13 App router] Routes without Edge Runtime
When building my app locally with
pnpm dlx @cloudflare/next-on-pages@latest
everything builds as expected, however, doing so on Cloudflare results in an error after the build has completed stating that my server components require export const runtime = "edge";
which has already been set in all of them and confirmed by the local build. I am using build system v2 though I don't believe that should impact this as I would require a newer nodejs version regardless of the underlying runner operating system (Ubuntu 20 vs 22)9 Replies
Hey there, would you be able to send your build log, please?
Everything before this looks like normal logs from
next-on-pages
and a warning from a library
The logs indicate that the routes listed don't have the required export but they do, I checked the commit from which it was built and it exists in there and also builds locally so I am just a little confusedThat is very strange indeed if your route has actually opted into the edge runtime and it builds locally. Would it be at all possible for you to create a repository where this behaviour can be reproduced?
I will give it a go and see, would you mind if I ping you here when that is done?
i don't mind, I'll see the message either way 😛
Alright, https://github.com/InBlue/cf-next13-build-issue this is a super simple repo but the same thing happens, works building locally but not in cloudflare
GitHub
GitHub - InBlue/cf-next13-build-issue
Contribute to InBlue/cf-next13-build-issue development by creating an account on GitHub.
Thank you. Ah,
next.config.js
option for i18n
. Yeah... The config-level internationalization option has been really problematic for us - the build that Next/Vercel produces for it often generates invalid functions that it probably shouldn't have. It has caused many issues in our testing that I have tried to account for, but then another one pops up around the corner. For me, the build with that repo fails locally because of nextjs/vercel generating invalid functions for the en
locale that we can't use.
Would it be possible for you to use an alternative approach to internationalization? In the app directory, the recommended way is to use middleware + a dynamic [lang]
at the root of your app instead - Next.js are actually trying to move away from people using the config i18n
option with the app directory.
https://nextjs.org/docs/app/building-your-application/routing/internationalization#routing-overviewOh, that is so simple! I will try removing that option to see if it builds as I expect. I am not using it at all right now, just was planning for the future so I can use whatever is most recommended anyway
Awesome!! That has fixed it! Such a simple fix which is great for me! Thank you so much
Glad to hear 🙂