#Navigating to api hello results in a
1 messages ยท Page 1 of 1 (latest)
I can't reproduce it here but you probably don't want to do return App.getInitialProps(ctx) in your _app
it results in an infinite loop because it is calling itself
App is from next/App not MyApp
It says to do this in the docs: https://nextjs.org/docs/advanced-features/custom-app#:~:text=When you add getInitialProps in your custom app%2C you must import App from "next/app"%2C call App.getInitialProps(appContext) inside getInitialProps and merge the returned object into the return value.
Here's a repro: https://github.com/AndrewLester/nextjs-repro
The repro doesn't work locally. It only happens on Vercel
The reason for this is because Next.js catches the infinite loop, but in the serverless environment new serverless contexts are created.
thanks, I reproduced it locally with your repo
Make sure to delete your deployment, it'll rack up requests quick ๐
oh wait you reproduced locally?
Oh cool, I wasn't able to do that
next.js always seemed to cut the requests out after 3 fails to render _error
so I don't really know why, but next is running App.getInitialProps when the api route is failing
and it makes another request to the api route
then it fails and runs App.gIP again which results in the infinite loop
It's strange. Sorry if I seem a bit argumentative here, i appreciate your help. This just sent an invoice of $1600 over the weekend...
Is the best move to contact Vercel to reimburse the charge (an unexpected bug), and then open a bug in Next.js?
Perhaps they know some edge case here
yeah I think you can create an issue in the repo first and check if the behavior is expected or not
I wasn't expecting it because the api routes don't render any layout at all
That's what I thought too... which is why I wrote it in the first place ๐
Welp, ok I'll do that. And when you reproduced it locally did it go infinitely, or just stop at 3? For me it stopped at 3 on local host, but on Vercel it kept going...
For reference I was setting BASE_URL to http://localhost:3000 and doing yarn build && yarn start
yeah I did the same thing
.env.local file with BASE_URL="http://localhost:3000" and just yarn dev
hm ok, well thanks again
oh wow that is infinite
let me know how it goes, I'm curious about this one 
oh wow I do get infinite requests now too... I was testing this the other day with a slightly different _app and i only got 3 before it stopped