Closed botond-veress closed 4 years ago
Thanks for reporting @botond-veress !
Could you post your serverless.yml
as well? We got a PR in progresss here (https://github.com/serverless-nextjs/serverless-next.js/pull/495) that may also fix this if my last suggestion in this comment is implemented.
I suspect there is something weird going on with S3 regional endpoints and the CloudFront distribution.
Also to get the project working locally for you this should help.
Thanks for the fast reply @danielcondemarin.
Here is the serverless.yml:
nextApp:
component: '@sls-next/serverless-component@1.15.0-alpha.5'
inputs:
domain:
- ${env.SUBDOMAIN}
- ${env.HOSTED_ZONE}
domainType: apex
bucketName: ${env.BUCKET_NAME}
bucketRegion: ${env.AWS_DEFAULT_REGION}
memory: 1024
Btw, I followed the CONTRIBUTING guide but as I said the yarn
fails, because during postinstall the lerna exec fails to install aws-sdk:
$ yarn
yarn install v1.21.1
[1/4] 🔍 Resolving packages...
success Already up-to-date.
$ yarn packages-install && opencollective-postinstall || true
yarn run v1.21.1
$ lerna exec -- yarn install --frozen-lockfile
lerna notice cli v3.22.1
lerna info versioning independent
lerna info Executing command in 10 packages: "yarn install --frozen-lockfile"
[1/4] 🔍 Resolving packages...
[1/4] 🔍 Resolving packages...
success Already up-to-date.
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
error https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.706.0.tgz: Extracting tar content of undefined failed, the file appears to be corrupt: "ENOENT: no such file or directory, stat '/Users/botondveress/Library/Caches/Yarn/v6/npm-aws-sdk-2.706.0-09f65e9a91ecac5a635daf934082abae30eca953-integrity/node_modules/aws-sdk/dist/aws-sdk-react-native.js'"
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
lerna ERR! yarn install --frozen-lockfile exited 1 in '@sls-next/cloudfront'
lerna ERR! yarn install --frozen-lockfile exited 1 in '@sls-next/cloudfront'
lerna WARN complete Waiting for 4 child processes to exit. CTRL-C to exit immediately.
error Command failed with exit code 1.
error https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.706.0.tgz: Extracting tar content of undefined failed,
Mmh that same error has happened on CI before a few times, never for me locally though. Probably worth starting by bumping the aws-sdk in the packages that is being used and see if that fixes it?
@danielcondemarin I opened a tiny PR so this can fixed until https://github.com/serverless-nextjs/serverless-next.js/pull/495 gets merged.
I've just published @sls-next/serverless-component@1.15.1 with your PR
Describe the bug I use this lib for a while now, and it always worked like a charm. Good job guys!
But lately, I noticed on new projects that public assets (favicon, robots.txt, basically anything in the public folder) cannot be loaded because I get a Cloudfront/S3 SignatureDoesNotMatch error. I couldn't find anybody reporting the same issue so I started digging deeper.
To Reproduce Steps to reproduce the behavior:
P.S I could reproduce the issue in "@sls-next/serverless-component@1.15.0-alpha.5" and "serverless-next.js@1.9.10" so most likely more versions are affected.
Expected behavior I should receive the file I requested instead of the SignatureDoesNotMatch error.
Screenshots
Desktop (please complete the following information):
Additional context As far as I know for public assets the default lambda@edge is being invoked. So I checked what happens there, and I found this in the handler:
It looks like for public assets the S3 domain name is not being normalized even though public assets are retrieved from the same S3 bucket as the static pages. So I deployed a modified version of the lambda which normalized it and it fixed the problem.
Can you confirm this is a proper solution?
P.S 2: I forked the repo and wanted to create a PR, but it looks like the
lerna exec
fails onmaster
and a lot of tests are failing in thelambda-at-edge
package, so I will let you fix it if this is the proper solution.