junjei
junjei

Reputation: 1

aws app running django static s3 url missing colon wrong url

this is my first post and i was to highlight a problenm that i've struggled with for a whole day.

While configuring my django project by recovering the static files from an s3 bucket i've ended up with a problem, the url prefixed in fron of the static resources was generating without : after the protocol, like this:

<link rel="shortcut icon" type="image/png" href="https//django-examplebucketname.s3.amazonaws.com/static/images/favicon.png">

so at the css, js and all the other static resources were giving 404.

in the tamplate i had: {% load static %} and

the settings file instead was configured like that:

WS_ACCESS_KEY_ID = "myid"
AWS_SECRET_ACCESS_KEY = "mykey"
AWS_STORAGE_BUCKET_NAME = "django-examplebucketname"
AWS_S3_REGION_NAME = "my-region"
AWS_S3_CUSTOM_DOMAIN = "django-examplebucketname.s3.amazonaws.com"


AWS_S3_URL_PROTOCOL = "https"
AWS_S3_USE_SSL = True
AWS_S3_VERIFY = True

AWS_LOCATION = "static/"
STATIC_URL = "https://django-examplebucketname.s3.amazonaws.com/static/"
STATICFILES_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"

but the static url was not taken in consideration and once released over apprunning the url was always missing the : (colon) after the protocol

no other configurations were applied over the project. With the local setting and whitenoise was working.

I've checked:

Upvotes: 0

Views: 114

Answers (1)

junjei
junjei

Reputation: 1

I was able to fix the problem myself

For some reason the property:

STATIC_URL = "https://django-examplebucketname.s3.amazonaws.com/static/"

was not considered at all.

I fixed for now

by commenting:

  • #AWS_S3_URL_PROTOCOL = "https"
  • #AWS_S3_VERIFY = True

and keep enabled only:

  • AWS_S3_USE_SSL = True

Hope this can help.

Upvotes: 0

Related Questions