From 0cdd7416e5dc8d0dec44ffa618d6fcb3ffc40a14 Mon Sep 17 00:00:00 2001 From: "sandro.meireles" Date: Tue, 21 May 2024 19:53:31 -0300 Subject: [PATCH] feat: Configure CORS --- apip/settings.py | 8 ++++++++ poetry.lock | 17 ++++++++++++++++- pyproject.toml | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/apip/settings.py b/apip/settings.py index 8272158..34afa06 100644 --- a/apip/settings.py +++ b/apip/settings.py @@ -45,11 +45,13 @@ "apip.testplans", "apip.testcases", "django_ace", + "corsheaders", ] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", + "corsheaders.middleware.CorsMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", @@ -145,3 +147,9 @@ # Mock settings FAKER_CLASS = "application.fackers.CLIJSFFaker" + + +# django-cors-headers Configurations + +CORS_ALLOWED_ORIGINS = env.list("CORS_ALLOWED_ORIGINS", default="") +CORS_ALLOW_ALL_ORIGINS = env.str("CORS_ALLOW_ALL_ORIGINS", default=DEBUG) diff --git a/poetry.lock b/poetry.lock index 9c581d8..244d412 100644 --- a/poetry.lock +++ b/poetry.lock @@ -250,6 +250,21 @@ files = [ [package.dependencies] Django = ">1.11" +[[package]] +name = "django-cors-headers" +version = "4.3.1" +description = "django-cors-headers is a Django application for handling the server headers required for Cross-Origin Resource Sharing (CORS)." +optional = false +python-versions = ">=3.8" +files = [ + {file = "django-cors-headers-4.3.1.tar.gz", hash = "sha256:0bf65ef45e606aff1994d35503e6b677c0b26cafff6506f8fd7187f3be840207"}, + {file = "django_cors_headers-4.3.1-py3-none-any.whl", hash = "sha256:0b1fd19297e37417fc9f835d39e45c8c642938ddba1acce0c1753d3edef04f36"}, +] + +[package.dependencies] +asgiref = ">=3.6" +Django = ">=3.2" + [[package]] name = "django-environ" version = "0.11.2" @@ -701,4 +716,4 @@ zstd = ["zstandard (>=0.18.0)"] [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "7fad88da5b255f807fba0109e850c3266a93e085e3712d1a151cb7b839f8ec46" +content-hash = "c9207364977dae7ce89177df3f5dd372f5cfe6375387507b3928d994671aa4a2" diff --git a/pyproject.toml b/pyproject.toml index fa14140..856c286 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,7 @@ django-environ = "^0.11.2" requests = "^2.31.0" django-ace = "^1.32.4" psycopg2 = "^2.9.9" +django-cors-headers = "^4.3.1" [tool.poetry.group.dev.dependencies]