AWS - Fix Next.js static site hosted on S3 CloudFront routing fails on page reload

Duplicate files without .html extension

find ./out -type f -name '*.html' | while read HTMLFILE; do
  BASENAME=${HTMLFILE##*/};
  FILENAME=${BASENAME%.*};
  if [[ "$FILENAME" != "index" ]];
  then
    cp ${HTMLFILE} ./out/${FILENAME};
  fi
done

Set explicit content type for any guessed mime types

--content-type text/html

aws s3 sync out s3://woomanpower --acl public-read --follow-symlinks --delete --content-type text/html

Last updated

Was this helpful?