Skip to content

Commit

Permalink
chore: /api
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed Mar 11, 2024
1 parent c644f8c commit 6d260dc
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 29 deletions.
6 changes: 3 additions & 3 deletions backend/ypovoli/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
https://docs.djangoproject.com/en/5.0/ref/settings/
"""

import os
from datetime import timedelta
from os import environ
from pathlib import Path
import os

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand Down Expand Up @@ -89,8 +89,8 @@
# Application endpoints

CAS_ENDPOINT = "https://login.ugent.be"
CAS_RESPONSE = "https://localhost:8080/auth/cas/echo"
API_ENDPOINT = "https://localhost:8080"
CAS_RESPONSE = "https://localhost:8080/api/auth/cas/echo"
API_ENDPOINT = "https://localhost:8080/api"

# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
Expand Down
43 changes: 28 additions & 15 deletions backend/ypovoli/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from django.urls import include, path
from django.urls import include, path, re_path
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
from rest_framework import permissions
Expand All @@ -33,18 +33,31 @@


urlpatterns = [
# Base API endpoints.
path("", include("api.urls")),
# Authentication endpoints.
path("auth/", include("authentication.urls")),
path("notifications/", include("notifications.urls"), name="notifications"),
# Swagger documentation.
path(
"swagger/",
schema_view.with_ui("swagger", cache_timeout=0),
name="schema-swagger-ui",
),
path(
"swagger<format>/", schema_view.without_ui(cache_timeout=0), name="schema-json"
),
re_path(
"api/",
include(
[
# Base API endpoints.
path("", include("api.urls")),
# Authentication endpoints.
path("auth/", include("authentication.urls")),
path(
"notifications/",
include("notifications.urls"),
name="notifications",
),
# Swagger documentation.
path(
"swagger/",
schema_view.with_ui("swagger", cache_timeout=0),
name="schema-swagger-ui",
),
path(
"swagger<format>/",
schema_view.without_ui(cache_timeout=0),
name="schema-json",
),
]
),
)
]
25 changes: 15 additions & 10 deletions data/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,37 @@ http {
}

server {
listen 443 ssl;
listen [::]:443 ssl;
listen 8080 ssl;
listen [::]:8080 ssl;

ssl_certificate ssl/certificate.crt;
ssl_certificate_key ssl/private.key;

location / {
proxy_pass http://frontend;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
return 301 https://$host$request_uri;
}
}

server {
listen 8080 ssl;
listen [::]:8080 ssl;
listen 443 ssl;
listen [::]:443 ssl;

ssl_certificate ssl/certificate.crt;
ssl_certificate_key ssl/private.key;

location /api/ {
proxy_pass https://backend$request_uri;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}


location / {
proxy_pass https://backend;
proxy_pass http://frontend;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
}
}
}
2 changes: 1 addition & 1 deletion development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ services:
build:
context: $BACKEND_DIR
dockerfile: Dockerfile
command: bash -c "./setup.sh && python manage.py runsslserver 192.168.90.2:8080"
command: /bin/bash -c "./setup.sh && python manage.py runsslserver 192.168.90.2:8080"
expose:
- 8000
volumes:
Expand Down

0 comments on commit 6d260dc

Please sign in to comment.