This commit is contained in:
zakhy 2024-09-20 14:58:39 +07:00
parent 0bdb466ffd
commit 4ea27a01e0
3 changed files with 23 additions and 21 deletions

View File

@ -5,7 +5,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY = os.environ.get('SECRET_KEY', 'django-debug-key')
DEBUG = os.environ.get('DEBUG', True)
DEBUG = bool(int(os.environ.get('DEBUG', True)))
ALLOWED_HOSTS = ['*']
@ -94,3 +94,5 @@ CORS_ALLOWED_ORIGINS = [
'http://localhost:443',
'http://localhost:80',
]
if DEBUG:
CORS_ALLOW_ALL_ORIGINS = True

View File

@ -6,7 +6,7 @@ from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
from django.views.decorators.http import require_POST, require_GET
from users.models import Token
@ -29,7 +29,7 @@ def login(request):
return JsonResponse({'token': token[0].token})
@require_POST
@require_GET
@csrf_exempt
def check_token(request):
auth_header = request.headers.get('Authorization')

View File

@ -1,24 +1,24 @@
version: '3.9'
services:
web:
build: ./app
# place image
command: >
sh -c "
python manage.py makemigrations --noinput &&
python manage.py migrate --noinput &&
python manage.py runserver 0.0.0.0:8000
"
ports:
- '8000:8000'
expose:
- 8000
env_file:
- .env
depends_on:
postgres:
condition: service_healthy
# web:
# build: ./app
# # place image
# command: >
# sh -c "
# python manage.py makemigrations --noinput &&
# python manage.py migrate --noinput &&
# python manage.py runserver 0.0.0.0:8000
# "
# ports:
# - '8000:8000'
# expose:
# - 8000
# env_file:
# - .env
# depends_on:
# postgres:
# condition: service_healthy
postgres:
image: postgres:15