nextjs-lambda
nextjs-lambda copied to clipboard
API calls to _next/data fails with a 404 in standalone deployment with AWS Lambda
I am building an SSR application with Next 13 with standalone output. No basepath. And I am using Page Router. We have certain places where we are doing client side navigation which is triggering an API call ( _next/data/buildId/index.json ) but it fails with a 404. Now, these requests are being sent to the Lambda but they fail and that results in a page refresh.
My questions were:
- In a standalone app, I can see we have code.zip and dependencies.zip, the two of which need to be deployed for Lambda. I dont see a file structure for <buildId>/index.json. Is there a need for these files to exist in the directory ?
- Is this a problem with Next 13 ?
Hey!
_next/data
are basically API route I believe. It's handled by Next's server.
'_next/data/*': {
...defaultOptions,
origin: serverOrigin,
},
What seems weird is that doubled //
in your path _next/data//index.json
. I would imagine that causing and issue probably. Question is, why is it doubled 🤔 Could you investigate the origin of this request (I would expect getServerSideProps
making it).
That was a typo. The request is expected. Origin of request is the client. When there is a client side navigation within the app on the same route ( but on a different query string parameter ), client makes a request to getServerSideProps in the form of /_next/data/buildId/index.json. However, it seems Lambda is not able to figure out what to make of it.
Not a typo. Happened because I used carets
I can spin up an example and share repo if that helps. I couldn't find much info on Next SSR Standalone + AWS Lambda but for your package's github. Let me know if that'd help in your investigation ( if you have time for this ofcourse )
@js-sapphire I tried replicating without much luck :/ could you try to share repo steps? I will try to support you, however, please consider EOL (#97) for this package.
Thanks @sladg Will share ASAP.
Closing, inactive :)