API routes return CloudFront 503 on `next` `12.0.9`
See original GitHub issue(I think this is a feature request, more than a bug 🤔)
Is your feature request related to a problem? Please describe.
When upgrading next
from 12.0.8
to 12.0.9
, API routes started to return a generic 503 from CloudFront.
- Update: I’m seeing the same error message that @jakubriedl posted ^1
TypeError: Cannot read property 'headers' of undefined
at Object.apiResolver (/var/task/chunks/89.js:10564:43)
at Module.<anonymous> (/var/task/chunks/89.js:6094:34)
A barebones API route (/api/health.ts
) would return a generic 503 CloudFront error
import { NextApiHandler } from "next";
const handler: NextApiHandler = async (req, res) => {
return res.status(200).send("OK");
};
export default handler;
Describe the solution you’d like
For these to just work with next
>= 12.0.9
🙏
"@sls-next/cdk-construct": "3.7.0-alpha.7",
"@sls-next/lambda-at-edge": "3.7.0-alpha.7",
Describe alternatives you’ve considered
Pin next
to 12.0.8
Additional context
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:32 (5 by maintainers)
Top Results From Across the Web
Amplify error 503 on Next.js api routes : r/aws - Reddit
js App with Prisma + Apollo into the api routes, but when I try to call an endpoint of Next.js app I get...
Read more >Nextjs TypeError: "Cannot read property 'headers' of ...
I'm using aws amplify. The following error is returned in the CloudFront console: My api route: const handlerProducts = async (req: ...
Read more >HTTP 503 status code (Service Unavailable) - 亚马逊云科技
You will receive this error in the rare situation that CloudFront can't route requests to the next best available edge location, and so...
Read more >Serverless Nextjs Pluginを試した所感について
... 半月ほどで修正されたりしています(API routes return CloudFront 503 on next 12.0.9 · Issue #2327 · serverless-nextjs/serverless-next.js)。
Read more >Next.js 11 on AWS Amplify - Preview not working
The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions. We can't connect to the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi everybody, I was having the 503 error today after setting up a pretty standard nextjs project using serverless-next.js 3.6.0, I thought it was a Lambda permission issue so I created a new role/policy but the error persisted, I’m using next 12.1.0 btw. Reading through the comments I saw some people mention the alpha pre-release so I tested 3.7.0-alpha.10 and boom, the default api that comes in the example project (api/hello) started working! I even removed the policy/role that I created and everything is still working just fine, I hope this helps someone too.
I apologize if this is not the right place to ask this question, but do you happen to know if AWS Amplify uses serverless-nextjs for deploying Next.js apps? When using Amplify to deploy our app I encounter the same issue (unless I switch to Next 12.0.8)