Closed socsieng closed 1 month ago
It should be a pretty easy fix, we probably just need to append the basePath if necessary here https://github.com/sst/open-next/blob/388b4e70824c08aaecd19b405611d23fba741b93/packages/open-next/src/core/routingHandler.ts#L147-L149
@conico974, I assume no one is working on this. I'll raise a PR.
Issue
NextJS app deployed using SST and OpenNext does not respect
basePath
property defined in NextJS config for API routes.I'd love to work on this but unfortunately I don't know where to start.
Potentially related to: https://github.com/sst/open-next/issues/508
Environment
Reproduction steps
Clone repository at https://github.com/socsieng/next-sst which includes detailed reproduction steps. Reproduction steps also included inline.
1.
create-next-app
and initialize SST2. Update the
next.config.mjs
file to include thebasePath
3. Add an API route at
app/api/hello/route.ts
4. Use latest version of
ope-next
insst.config.ts
3.1.3
at the time of writing.5. Deploy the app
6. Open the following URLs in the browser
Replace
assignedhost
with the actual CloudFront distribution URL.Expected results
Both 6.1 and 6.2 return successful responses.
Actual results
6.1 returns a successful response, but 6.2 returns a 404 error. Note that changing the URL for 6.2 to exclude the
basePath
(https://assignedhost.cloudfront.net/api/hello) works.Note that this works as expected with
sst dev
: