You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the Next.js project is created using a monorepo structure and deployed using the SST NextjsSite construct, the server function fails when the region where the user is located is different from the S3 cache bucket.
PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
Cause
When OpenNext identifies a monorepo structure, it calls the addMonorepoEntrypoint function and creates a index.js exporting the handler inside the project package:
However, the way node.js works the imports run before the process.env block, the CACHE_BUCKET_REGION is not defined and the S3Client is defined without the right region:
Issue
When the Next.js project is created using a monorepo structure and deployed using the SST
NextjsSite
construct, the server function fails when the region where the user is located is different from the S3 cache bucket.Cause
When OpenNext identifies a monorepo structure, it calls the
addMonorepoEntrypoint
function and creates aindex.js
exporting the handler inside the project package:Source reference:
addMonorepoEntrypoint](https://github.com/sst/open-next/blob/3a5755fdcbfdf688cedc355e892b5ed74787993f/packages/open-next/src/build.ts#L712-L725)
SST adds the following code before the
export *
and the final code looks like:However, the way node.js works the imports run before the
process.env
block, theCACHE_BUCKET_REGION
is not defined and theS3Client
is defined without the right region:https://github.com/sst/open-next/blob/3a5755fdcbfdf688cedc355e892b5ed74787993f/packages/open-next/src/adapters/server-adapter.ts#L33-L37
The text was updated successfully, but these errors were encountered: