https://sparta-games.net/games/list/47/ <– !! Sound Too Loud !!
I’m trying to lower the sound of iframe or the whole page.
The exact error message:
47/:644 Uncaught DOMException: Failed to read a named property 'AudioContext' from 'Window': Blocked a frame with origin "http://127.0.0.1:8000" from accessing a cross-origin frame.
at iframe_element.onload (http://127.0.0.1:8000/games/list/47/:644:58)
Iframe is a Unity WebGL game which is coming from S3 bucket.
I’m using Django, EC2, mobaXterm, S3, nginx, gunicorn, RDS. (Windows11)
My settings
Django settings.py:
INSTALLED_APPS = [
...,
"corsheaders",
...,
]
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
...,
'django.middleware.common.CommonMiddleware',
...,
]
X_FRAME_OPTIONS = 'SAMEORIGIN'
CORS_ALLOWED_ORIGINS = [
"http://127.0.0.1:8000",
]
S3 CORS policy:
{
"CORSRules": [
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"PUT",
"HEAD"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": [
"x-amz-server-side-encryption",
"x-amz-request-id",
"x-amz-id-2"
],
"MaxAgeSeconds": 3000
}
]
}
versions:
Django==4.2
django-cors-headers==4.3.1
Sending header through views.py like below didn’t help either.
def my_view(request):
response = JsonResponse({'message': 'Hello, world!'})
response['Access-Control-Allow-Origin'] = 'http://127.0.0.1:8000'
response['Access-Control-Allow-Methods'] = 'GET, POST, OPTIONS'
response['Access-Control-Allow-Headers'] = 'Content-Type'
return response
I can’t find the exact case like this.
Recursively asked ChatGPT to solve it.
django-cors-headers, s3 policy, directly sending headers, cors whitelist,…
didn’t get the problem.
In fact, this also happen when user to modify and submit any content of this page.(CORS thing)
I’m on this problem almost 4days long. Please help me.
Jinyong Han is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.