From cb15b6d803309f6a9f07c7baf088a252742dd28d Mon Sep 17 00:00:00 2001 From: hoischreck Date: Wed, 3 Apr 2024 20:42:34 +0200 Subject: [PATCH] backend api protocol is set dynamically --- client/src/App.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/src/App.js b/client/src/App.js index b7fb8ce8..db539370 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -5,10 +5,11 @@ function App() { const [products, setProducts] = useState([]); const hostname = window.location.hostname; - + const protocol = window.location.protocol; + const fetchProducts = async () => { const { data } = await Axios.get( - `http://${hostname}:3001/api/items/` + `${protocol}//${hostname}:3001/api/items/` ); const products = data; setProducts(products);