Commit dd308932 authored by Traas, J.J.'s avatar Traas, J.J.
Browse files

Merge branch '17-integrate-proxy-into-backend-server' into 'master'

Resolve "Integrate proxy into backend server"

Closes #17

See merge request !1
parents b215bb91 4bede09a
......@@ -2,3 +2,4 @@ DATABASE_URL=postgres:///dashit
DJANGO_SECRET_KEY=development_secret_key
DJANGO_DEBUG=on
FRONTEND_URL=http://localhost:8000/#/
ANALYTICS_URL=http://localhost:8001/api/
\ No newline at end of file
......@@ -16,6 +16,7 @@ django-cors-middleware = "*"
django-rest-framework = "*"
django-dotenv = "*"
sqlparse = "*"
django-proxy = "*"
[dev-packages]
"flake8" = "*"
......
This diff is collapsed.
......@@ -25,6 +25,7 @@ PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
SECRET_KEY = os.environ["DJANGO_SECRET_KEY"]
FRONTEND_URL = os.environ.get("FRONTEND_URL", "http://localhost:8080/#/")
ANALYTICS_URL = os.environ.get("ANALYTICS_URL", "http://localhost:8001/api/")
if not FRONTEND_URL.endswith("#/"):
FRONTEND_URL += "#/"
......
......@@ -16,11 +16,12 @@ Including another URLconf
import oauth2_provider.urls
from django.contrib import admin
from django.urls import include, path
from django.urls import include, path, re_path
import courses.routers
import users.routers
import users.urls
from eit_dashboard.views import ApiProxyView
urlpatterns = [
path("admin/", admin.site.urls),
......@@ -28,4 +29,5 @@ urlpatterns = [
path("o/", include((oauth2_provider.urls.base_urlpatterns, "oauth2_provider"))),
path("", include(users.routers)),
path("", include(courses.routers)),
re_path("api/(?P<path>.*)", ApiProxyView),
]
from django.views.decorators.csrf import csrf_exempt
from proxy.views import proxy_view
from eit_dashboard.settings import ANALYTICS_URL
# TODO: This assumes there is only one analytics server
@csrf_exempt
def ApiProxyView(request, path):
remoteurl = ANALYTICS_URL + path
return proxy_view(request, remoteurl)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment