Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API calls to _next/data fails with a 404 in standalone deployment with AWS Lambda #98

Open
js-sapphire opened this issue Dec 21, 2023 · 5 comments

Comments

@js-sapphire
Copy link

js-sapphire commented Dec 21, 2023

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 /index.json. Is there a need for these files to exist in the directory ?
  • Is this a problem with Next 13 ?
@sladg
Copy link
Owner

sladg commented Dec 21, 2023

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).

@js-sapphire
Copy link
Author

js-sapphire commented Dec 21, 2023

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

@js-sapphire
Copy link
Author

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 )

@sladg
Copy link
Owner

sladg commented Dec 21, 2023

@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.

@js-sapphire
Copy link
Author

Thanks @sladg
Will share ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants