diff --git a/server/apps/research/urls.py b/server/apps/research/urls.py index c019aca..039e12d 100644 --- a/server/apps/research/urls.py +++ b/server/apps/research/urls.py @@ -3,12 +3,13 @@ from .views import ArticleViewSet, index from django.conf import settings from django.conf.urls.static import static +from .utils import astro_proxy router = DefaultRouter() router.register(r'articles', ArticleViewSet, basename='article') urlpatterns = [ - path('', index, name='index'), + path('', astro_proxy, name='astro_proxy'), path('api/', include(router.urls)), # Custom URL for retrieving articles by slug or UUID diff --git a/server/apps/research/utils.py b/server/apps/research/utils.py new file mode 100644 index 0000000..c76f048 --- /dev/null +++ b/server/apps/research/utils.py @@ -0,0 +1,6 @@ +from django.http import HttpResponse +import requests + +def astro_proxy(request): + response = requests.get('http://localhost:4321' + request.path) + return HttpResponse(response.content, content_type=response.headers['Content-Type']) \ No newline at end of file diff --git a/server/apps/research/views.py b/server/apps/research/views.py index b9e2385..fd16c5e 100644 --- a/server/apps/research/views.py +++ b/server/apps/research/views.py @@ -3,6 +3,7 @@ from django.shortcuts import render from rest_framework import viewsets, status from rest_framework.response import Response +from .utils import astro_proxy import uuid from .models import Article @@ -10,7 +11,7 @@ from .serializers import ArticleSerializer, ArticleCreateUpdateSerializer def index(request): - return render(request, 'index.html') + return astro_proxy(request) class ArticleViewSet(viewsets.ModelViewSet): diff --git a/server/core/config/base.py b/server/core/config/base.py index 09ddeac..3dbe37f 100644 --- a/server/core/config/base.py +++ b/server/core/config/base.py @@ -190,3 +190,4 @@ from .ckeditor import * from .celery_config import * from .mail import * + diff --git a/server/core/config/production.py b/server/core/config/production.py index e510af9..5303899 100644 --- a/server/core/config/production.py +++ b/server/core/config/production.py @@ -57,4 +57,7 @@ SECURE_SSL_REDIRECT = False -SESSION_COOKIE_SECURE = True \ No newline at end of file +SESSION_COOKIE_SECURE = True + +#PROXY_SETTING for Astro server +PROXY_ASTERISK = True \ No newline at end of file