I have a react app uploaded on aws s3, this is the command I am using to deploy it
npm i
npm run build
aws s3 sync build s3://bucket/path --acl=public-read --delete
aws cloudfront create-invalidation --distribution-id XXX --paths "/*"
Then I have many errors like
Loading chunk X failed
or
Loading CSS chunk X failed
I was thinking it was due to cache issue after deployment, bet now I didn't deploy for a week and the error rate does not decrease.
For example, the error is Loading CSS chunk 6 failed. (/static/css/6.32a7316b.chunk.css)
then when I go to https://my-website.com/static/css/6.32a7316b.chunk.css the file is loaded without issue
I read many posts but can not find any solution, some were talking about CORS configuration but should not be an issue as the file are coming from the same domain
There is maybe some cache rule to define, but I do not really know which one and where.
I am also using Cloudflare between the client and S3 I do not know if it has an impact