From 98041314dd0fa78a2d44bf6c361160c8b30cda7d Mon Sep 17 00:00:00 2001 From: Sofia Bilous Date: Sun, 24 Sep 2023 14:19:20 +0300 Subject: [PATCH 1/5] whitelist --- forum/settings.py | 3 ++- sample.env | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/forum/settings.py b/forum/settings.py index 7746844cf..a7d707f6b 100644 --- a/forum/settings.py +++ b/forum/settings.py @@ -65,9 +65,10 @@ CORS_ALLOW_ALL_ORIGINS = False CORS_ORIGIN_WHITELIST = [ - 'http://localhost:3000', + 'http://localhost', 'http://127.0.0.1', 'http://0.0.0.0', + config('CORS_ORIGIN_WHITELIST'), ] CORS_ALLOWED_ORIGINS = [ diff --git a/sample.env b/sample.env index 711ec69b4..d77d7aa2e 100644 --- a/sample.env +++ b/sample.env @@ -1,3 +1,4 @@ +#db details SECRET_KEY= PG_DB= PG_USER= @@ -5,9 +6,13 @@ PG_PASSWORD= DB_HOST= DB_PORT= +#SMTP EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend EMAIL_HOST= EMAIL_PORT= EMAIL_USE_TLS= EMAIL_HOST_USER= EMAIL_HOST_PASSWORD= + +#origin hostnames allowed to make cross-site HTTP requests +CORS_ORIGIN_WHITELIST= From b164556726ee6fc1fb2a0a53a0ae0932922e3ee3 Mon Sep 17 00:00:00 2001 From: Sofia Bilous Date: Sun, 24 Sep 2023 15:32:10 +0300 Subject: [PATCH 2/5] add .env to frontend --- .gitignore | 1 + FrontEnd/package-lock.json | 23 +++++++++++++++++++---- FrontEnd/package.json | 3 +++ FrontEnd/sample.env | 0 forum/settings.py | 2 +- 5 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 FrontEnd/sample.env diff --git a/.gitignore b/.gitignore index 03f68be4d..d9c46cded 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /venv /.venv /.env +/*/.env /.DS_Store __pycache__/ /FrontEnd/node_modules diff --git a/FrontEnd/package-lock.json b/FrontEnd/package-lock.json index 783f784a8..c854d9348 100644 --- a/FrontEnd/package-lock.json +++ b/FrontEnd/package-lock.json @@ -25,6 +25,9 @@ "swr": "^2.2.2", "validator": "^13.11.0", "web-vitals": "^2.1.4" + }, + "devDependencies": { + "dotenv": "^16.3.1" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -7309,11 +7312,15 @@ } }, "node_modules/dotenv": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", - "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", + "dev": true, "engines": { - "node": ">=10" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" } }, "node_modules/dotenv-expand": { @@ -14780,6 +14787,14 @@ } } }, + "node_modules/react-scripts/node_modules/dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "engines": { + "node": ">=10" + } + }, "node_modules/react-transition-group": { "version": "4.4.5", "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz", diff --git a/FrontEnd/package.json b/FrontEnd/package.json index 1f2d344cc..99b235d83 100644 --- a/FrontEnd/package.json +++ b/FrontEnd/package.json @@ -44,5 +44,8 @@ "last 1 firefox version", "last 1 safari version" ] + }, + "devDependencies": { + "dotenv": "^16.3.1" } } diff --git a/FrontEnd/sample.env b/FrontEnd/sample.env new file mode 100644 index 000000000..e69de29bb diff --git a/forum/settings.py b/forum/settings.py index a7d707f6b..6f6df534c 100644 --- a/forum/settings.py +++ b/forum/settings.py @@ -72,7 +72,7 @@ ] CORS_ALLOWED_ORIGINS = [ - 'http://localhost:3000', + 'http://localhost', 'http://127.0.0.1', 'http://0.0.0.0', ] From 131bb477193f9e718e86ea2558dc3f8c9450e3da Mon Sep 17 00:00:00 2001 From: Sofia Bilous Date: Sun, 24 Sep 2023 15:52:46 +0300 Subject: [PATCH 3/5] fix .env in root directory --- FrontEnd/.gitignore | 1 + FrontEnd/sample.env | 1 + FrontEnd/src/App.js | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 FrontEnd/.gitignore diff --git a/FrontEnd/.gitignore b/FrontEnd/.gitignore new file mode 100644 index 000000000..4cb512ec1 --- /dev/null +++ b/FrontEnd/.gitignore @@ -0,0 +1 @@ +/.env \ No newline at end of file diff --git a/FrontEnd/sample.env b/FrontEnd/sample.env index e69de29bb..445288342 100644 --- a/FrontEnd/sample.env +++ b/FrontEnd/sample.env @@ -0,0 +1 @@ +REACT_APP_API_URL= \ No newline at end of file diff --git a/FrontEnd/src/App.js b/FrontEnd/src/App.js index b71e2d975..0775b148b 100644 --- a/FrontEnd/src/App.js +++ b/FrontEnd/src/App.js @@ -1,11 +1,11 @@ import React from 'react'; import './App.css'; import { BrowserRouter, Routes, Route } from 'react-router-dom'; -import AdminPage from "./components/adminPage/AdminPage"; -import BasicPage from "./components/basicPage/BasicPage"; - +import AdminPage from './components/adminPage/AdminPage'; +import BasicPage from './components/basicPage/BasicPage'; function App() { + console.log('************************', process.env.REACT_APP_API_URL); return (
From e9973754d16f6d3896e4da25b380eb5308f619fd Mon Sep 17 00:00:00 2001 From: Sofia Bilous Date: Sun, 24 Sep 2023 15:55:23 +0300 Subject: [PATCH 4/5] delete gitignore --- FrontEnd/.gitignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 FrontEnd/.gitignore diff --git a/FrontEnd/.gitignore b/FrontEnd/.gitignore deleted file mode 100644 index 4cb512ec1..000000000 --- a/FrontEnd/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.env \ No newline at end of file From 6376aa451aee0001daa54c9bdeb8961ef3d186aa Mon Sep 17 00:00:00 2001 From: Sofia Bilous Date: Sun, 24 Sep 2023 16:54:13 +0300 Subject: [PATCH 5/5] delete console.log --- FrontEnd/src/App.js | 1 - 1 file changed, 1 deletion(-) diff --git a/FrontEnd/src/App.js b/FrontEnd/src/App.js index 0775b148b..f7b3325c1 100644 --- a/FrontEnd/src/App.js +++ b/FrontEnd/src/App.js @@ -5,7 +5,6 @@ import AdminPage from './components/adminPage/AdminPage'; import BasicPage from './components/basicPage/BasicPage'; function App() { - console.log('************************', process.env.REACT_APP_API_URL); return (