Django 存储对 s3 静态文件使用不正确的 url

Django storages using incorrect urls for s3 static files

我正在使用 Django 存储在 s3 上托管我的静态文件(css、js、图像)。当我加载我的网页时,django 一直指向我的 s3 public 存储桶的不正确 url。例如,尽管文件 https://mysite.s3-ap-southeast-2.amazonaws.com/assets/images/cat.png

的正确 public url 仍然返回 https://mysite.amazonaws.com/assets/images/cat.png

settings.py

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
AWS_ACCESS_KEY_ID = os.environ.get('aws_access_key_id')
AWS_SECRET_ACCESS_KEY = os.environ.get('aws_secret_key')
AWS_STORAGE_BUCKET_NAME = 'mysite'
AWS_DEFAULT_ACL = "private"
AWS_S3_SIGNATURE_VERSION = "s3v4"
AWS_S3_REGION_NAME = 'ap-southeast-2'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
]
STATIC_URL = 'https://mysite.s3-ap-southeast-2.amazonaws.com/static/'
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'

尝试设置一个 s3 自定义域。

AWS_S3_CUSTOM_DOMAIN = 'mysite.s3-ap-southeast-2.amazonaws.com'