I uploaded to AWS CloudFront my Next JS app, with the following commands:
Creating my Nextjs app:
npx create-next-app
Create a serverless app with npx serverless using aws-nodejs template:
npx serverless create --template aws-nodejs
Updated my serveless.yml defining as serveless next component:
myNextApp:
component: "@sls-next/[email protected]"
Finally deploying my app in CloudFront:
npx serverless
This work fine! Only a doubt.... my Cloud front distribution has as origin S3 located as default in us-east-1, ¿how can I change the origin S3 region? I need it will be in eu-central-1. Is it possible to change the S3 region on deployment?
I had the same issue. You can't change the server region afterwards. I deleted everything (.serverless and .next-serverless folders that were created) and changed the serverless.yml. Add the following in your serverless.yml file:
myNextApp:
component: "@sls-next/[email protected]"
inputs:
bucketName: nameforyourbucket
bucketRegion: eu-central-1
And deploy using npx serverless