Skip to content

Commit

Permalink
Fix CORS not working #45
Browse files Browse the repository at this point in the history
  • Loading branch information
geofranzi committed Feb 15, 2024
1 parent bb5fdd2 commit 5d50afa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
'allauth',
'allauth.account',
'authapi',
'corsheaders',
'cronjobs',
'djgeojson',
'dj_rest_auth',
Expand All @@ -95,6 +96,7 @@
'csw',
'swos',
'phaenopt',
'climate',
# Your stuff: custom apps go here
]
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
Expand Down Expand Up @@ -143,6 +145,8 @@
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#middleware
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand Down Expand Up @@ -195,7 +199,7 @@
# https://docs.djangoproject.com/en/dev/ref/settings/#media-root
MEDIA_ROOT = str(APPS_DIR / "media")
# https://docs.djangoproject.com/en/dev/ref/settings/#media-url
MEDIA_URL = SUBDIR + '/media/'
MEDIA_URL = "/media/"

# TEMPLATES
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -249,6 +253,7 @@
SESSION_COOKIE_HTTPONLY = True
# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-httponly
CSRF_COOKIE_HTTPONLY = True
CSRF_TRUSTED_ORIGINS = ['http://leutra.geogr.uni-jena.de']
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-browser-xss-filter
SECURE_BROWSER_XSS_FILTER = True
# https://docs.djangoproject.com/en/dev/ref/settings/#x-frame-options
Expand Down Expand Up @@ -368,16 +373,17 @@
}

# django-cors-headers - https://github.com/adamchainz/django-cors-headers#setup
CORS_URLS_REGEX = r"^/(api|users|datasets|viz|search|projects|iknow|viz_smon|planthub.kg_visualization)/.*$"
CORS_URLS_REGEX = r"^/(api|users|datasets|viz|search|projects|iknow|viz_smon|planthub.kg_visualization|climate)/.*$"

# Your stuff...
# ------------------------------------------------------------------------------
# Allow all or only a certain address
# CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOWED_ORIGINS = [
'http://127.0.0.1:5173',
]
CORS_ALLOW_HEADERS = ('Authorization', 'Content-Type', 'Cache-Control', 'X-Requested-With')
CORS_ORIGIN_ALLOW_ALL = True
# CORS_ALLOWED_ORIGINS = [
# 'http://127.0.0.1:5173',
# ]

# CORS_ALLOW_HEADERS = ('Authorization', 'Content-Type', 'Cache-Control', 'X-Requested-With')

# BLAZEGRAPH Settings
BLAZEGRAPH_URL = 'http://localhost:9999/'
Expand Down
2 changes: 1 addition & 1 deletion config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
default="hi9QXEFQEh0dzRTv7igcf63fBfmk0t97bB5NJcNWSxw1KCo0QLiNqpI6d979ZypS",
)
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1", "10.149.0.38", "iknow.inf-bb.uni-jena.de"]
ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1", "10.149.0.38", "iknow.inf-bb.uni-jena.de", "leutra.geogr.uni-jena.de", "tippecc.github.io"]
X_FRAME_OPTIONS = 'allow-from http://127.0.0.1:5173/'

# Using postgresSQL change local db settings here (postgres://USERNAME:PASSWORD@HOST:PORT/DATABASENAME
Expand Down

0 comments on commit 5d50afa

Please sign in to comment.