Skip to content

Commit b6cad25

Browse files
committed
fix: this time actually fix CORS issues, like for real for real no cap
1 parent e824ecb commit b6cad25

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description = "Add your description here"
55
readme = "README.md"
66
requires-python = ">=3.13"
77
dependencies = [
8+
"django-cors-headers>=4.7.0",
89
"django-rest-framework>=0.1.0",
910
"django>=5.1.7",
1011
"drf-spectacular>=0.28.0",

src/ledger/settings.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@
2626
# SECURITY WARNING: don't run with debug turned on in production!
2727
DEBUG = bool(os.environ.get("DJANGO_DEBUG", default="1"))
2828

29-
ALLOWED_HOSTS = ["*"]
29+
ALLOWED_HOSTS = ["*"] if DEBUG else ["ledger.unitystation.org"]
3030

3131
# CSRF
3232
CSRF_TRUSTED_ORIGINS = ['https://ledger.unitystation.org']
33-
CORS_ORIGIN_ALLOW_ALL = DEBUG
34-
CORS_ALLOWED_ORIGINS = ['https://ledger.unitystation.org']
33+
34+
# CORS
35+
CORS_ALLOW_ALL_ORIGINS = True
36+
CORS_ALLOW_METHODS = ["GET", "HEAD", "OPTIONS"]
37+
3538
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
3639

3740
# Application definition
@@ -44,13 +47,15 @@
4447
'django.contrib.messages',
4548
'whitenoise.runserver_nostatic',
4649
'django.contrib.staticfiles',
50+
'corsheaders',
4751
'rest_framework',
4852
'transactions',
4953
'drf_spectacular'
5054
]
5155

5256
MIDDLEWARE = [
5357
'django.middleware.security.SecurityMiddleware',
58+
'corsheaders.middleware.CorsMiddleware',
5459
'whitenoise.middleware.WhiteNoiseMiddleware',
5560
'django.contrib.sessions.middleware.SessionMiddleware',
5661
'django.middleware.common.CommonMiddleware',

uv.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)