From d6096825e7f99dbc14c1848fe69275c3cc850d0e Mon Sep 17 00:00:00 2001 From: Francesco Grazioso Date: Mon, 29 Apr 2024 15:04:04 +0200 Subject: [PATCH] add cors --- api/api/settings.py | 15 +++++++++++++++ requirements.txt | Bin 204 -> 260 bytes 2 files changed, 15 insertions(+) diff --git a/api/api/settings.py b/api/api/settings.py index b7dd350..a45b242 100644 --- a/api/api/settings.py +++ b/api/api/settings.py @@ -37,11 +37,13 @@ INSTALLED_APPS = [ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "corsheaders", "endpoints", "rest_framework", ] MIDDLEWARE = [ + "corsheaders.middleware.CorsMiddleware", "django.middleware.security.SecurityMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", @@ -123,3 +125,16 @@ STATIC_URL = "static/" # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" + +CORS_ALLOWED_ORIGINS = [ + "http://localhost:5173", +] + +CORS_ALLOW_METHODS = ( + "DELETE", + "GET", + "OPTIONS", + "PATCH", + "POST", + "PUT", +) diff --git a/requirements.txt b/requirements.txt index 526461ed6043355dbbdb3f461c27f04ee4a38fe3..1c8240ceaa439402a76335379545786aa37abc1f 100644 GIT binary patch delta 63 zcmX@Z*upg7j0GV!Z delta 6 NcmZo+I>R{O3;+m60