message: fix(s3-static-assets): cover regional cn endpoints
diff: @@ -48,6 +48,15 @@ export type Credentials = {
  sessionToken?: string;
  };
  +const getS3RegionalEndpoint = (bucketRegion: string): string => {
  + // TODO: doesn't cover all endpoints but should be majority.
  + // We should ugprade to AWS SDK JS v3 so we don't need to manually manage.
  + return (
  + `https://s3.${bucketRegion}.amazonaws.com` +
  + `${bucketRegion.startsWith("cn-") ? ".cn" : ""}`
  + );
  +};
  +
  export default async ({
  bucketName,
  bucketRegion,
  @@ -56,7 +65,7 @@ export default async ({
  let s3 = new AWS.S3({
  ...credentials,
  region: bucketRegion,
  - endpoint: `https://s3.${bucketRegion}.amazonaws.com`,
  + endpoint: getS3RegionalEndpoint(bucketRegion),
  s3BucketEndpoint: false
  });
  @@ -71,7 +80,7 @@ export default async ({
  s3 = new AWS.S3({
  ...credentials,
  region: bucketRegion,
  - endpoint: `https://s3.${bucketRegion}.amazonaws.com`,
  + endpoint: getS3RegionalEndpoint(bucketRegion),
  s3BucketEndpoint: false,
  useAccelerateEndpoint: true
  });
  