I get this error:
ClientError at /dashboard/add-profile-details
An error occurred (400) when calling the HeadObject operation: Bad Request
Request Method: POST
Request URL: https://www.karlowebsytz.com/dashboard/add-profile-details
Django Version: 5.0.6
Exception Type: ClientError
Exception Value:
An error occurred (400) when calling the HeadObject operation: Bad Request
Exception Location: /var/task/botocore/client.py, line 1021, in _make_api_call
Raised during: dashboard.views.create_profile
Python Executable: /var/lang/bin/python3.12
Python Version: 3.12.3
Python Path:
[‘/var/task’,
‘/opt/python/lib/python3.12/site-packages’,
‘/opt/python’,
‘/var/lang/lib/python3.12/site-packages’,
‘/var/runtime’,
‘/var/lang/lib/python312.zip’,
‘/var/lang/lib/python3.12’,
‘/var/lang/lib/python3.12/lib-dynload’,
‘/var/lang/lib/python3.12/site-packages’,
‘/opt/python/lib/python3.12/site-packages’,
‘/opt/python’]
Server time: Thu, 11 Jul 2024 12:24:06 +0000
This is my settings.py configuration
AWS_ACCESS_KEY_ID = 'myid'
AWS_SECRET_ACCESS_KEY = 'mykey' #(I have the actual values in my project)
AWS_STORAGE_BUCKET_NAME = 'karlowebsytz'
AWS_S3_REGION_NAME = 'us-east-1'
AWS_QUERYSTRING_AUTH = False
AWS_S3_CUSTOM_DOMAIN = f'{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com'
AWS_S3_FILE_OVERWRITE = False
AWS_S3_OBJECT_PARAMETERS = {
'CacheControl': 'max-age=86400',
}
AWS_LOCATION = 'media'
MEDIA_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/{AWS_LOCATION}/'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
This is my Vercel.json file
{
"version": 2,
"builds": [
{
"src": "karlowebsytzweb/wsgi.py",
"use": "@vercel/python",
"config": { "maxLambdaSize": "15mb", "runtime": "python3.9" }
}
],
"routes": [
{
"src": "/(.*)",
"dest": "karlowebsytzweb/wsgi.py"
}
]
}
My s3 policy and cors are below
{
"Version": "2012-10-17",
"Id": "Policy1720667374556",
"Statement": [
{
"Sid": "Stmt1720667373352",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject",
"s3:ListBucket",
"s3:PutObjectAcl"
],
"Resource": [
"arn:aws:s3:::karlowebsytz",
"arn:aws:s3:::karlowebsytz/*"
]
}
]
}
and cors
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"PUT",
"POST",
"DELETE"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": []
}
]
I was trying to upload files in my website forms but when I submit I get 404 and sometimes 400 error code but my website works fine when I am submitting forms on my local server.