sst / ion

SST v3
https://sst.dev
MIT License
2.11k stars 247 forks source link

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

Open ekasprzyk opened 2 months ago

ekasprzyk commented 2 months ago

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.

jayair commented 1 month ago

I wonder about Next 12 in this case.

You can try asking the https://open-next.js.org repo, or #open-next in our Discord as well.

ekasprzyk commented 1 month ago

@jayair Thanks. I've asked the OpenNext community!