I see you are trying to run main js file which is generated after build in case of ssr. To run that you need a script or Procfile as per aws documentation. To do this I added Procfile to my s3 bucket and then run the build command
buildspec file
build:
commands:
- echo Build started
- npm run build:ssr
post_build:
commands:
- aws s3 cp s3://yourbucketname/Procfile ./dist
- bash -c "if [ /"$CODEBUILD_BUILD_SUCCEEDING/" == /"0/" ]; then exit 1; fi"
# - aws s3 rm s3://devemr.growthemr.com --recursive
- echo S3 bucket is cleared.
# - aws cloudfront create-invalidation --distribution-id=E26GLI30EJTNBB --paths '/*'
artifacts:
files:
- '**/*'
base-directory: 'dist'
Also, don’t forget to add the permission in your s3 bucket like below
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::bucketname",
"arn:aws:s3:::bucketname/*"
]
}
]
}
CLICK HERE to find out more related problems solutions.