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 routes in NextJS don't return any data #501

Open
ekasprzyk opened this issue Aug 30, 2024 · 1 comment
Open

API routes in NextJS don't return any data #501

ekasprzyk opened this issue Aug 30, 2024 · 1 comment

Comments

@ekasprzyk
Copy link

Over on SST Ion we posted this issue:

sst/ion#861

We've just tried moving from Serverless Components to SST for the deployment of our disposable branch environments and we're trying to replace that with SST before we think about moving the main site over.

We've had a lot of luck getting our site working on SST, but there's one thing that is behaving a bit weird that we just can't figure out. Not sure if this is a bug or just a documentation/concept error or whatever. So I'll just ask our question here as I haven't been able to find any information on it at all.

We have a NextJS 12.x site which we deploy via serverless components. That deploy uses Cloudfront and has an s3 bucket with default and API lambdas attached to it.

We've tried redeploying the same thing with SST and it's worked, mostly. We can see the site, some content even loads. We're nearly there. But, for reasons we don't understand, the `/api' routes are not returning data. We can see the routes being called in logs, we can see the current status being returned (e.g. one of our routes returns 500 due to a misconfiguration we haven't fixed, and that's correct, others return correct 200s). But no JSON. No data is being returned.

When trying to understand it a bit better, we notice that there is no longer an API lambda in the deployment, but that everything goes through the default lambda and we think that's normal based on the diagram of the system architecture.

Any advice on what we're doing wrong? And if so, any documentation that could be written to help others (assuming we're not being idiots)?

Also, we're noticing there aren't any edge functions that we can obviously tell in Cloudfront, and don't know if we have some issues with that as well.

One of the responders there mentioned it could be an issue with us using Next 12 and suggested we ask here. Any ideas, and does it seem most likely (as they suggest) that our issue is due to using Next 12 with the latest version of OpenNext?

Thanks!

@khuezy
Copy link
Collaborator

khuezy commented Aug 30, 2024

You should upgrade to the latest 14, there are some breaking changes from 12 => 13, but it should be pretty minor.

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