Skip to content

Commit

Permalink
add VITE_API_URL .env variable for local & production
Browse files Browse the repository at this point in the history
  • Loading branch information
DrCBeatz committed Mar 16, 2024
1 parent 1c32beb commit bb6c7f1
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.env
.env.production
.env.local
*.pyc
*.pyo
*.pyd
Expand Down
4 changes: 2 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@fortawesome/fontawesome-free": "^6.5.1",
"chart.js": "^4.4.2",
"mdb-react-ui-kit": "git+https://oauth2:VWmSVN7q3SGDUX_dguTV@git.mdbootstrap.com/mdb/react/mdb5/prd/mdb5-react-ui-kit-pro-essential",
"mdb-react-ui-kit": "git+https://oauth2:[api-key-redacted]@git.mdbootstrap.com/mdb/react/mdb5/prd/mdb5-react-ui-kit-pro-essential",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
22 changes: 14 additions & 8 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ function App() {
useEffect(() => {
const fetchAlgorithms = async () => {
try {
const response = await fetch("http://localhost:8000/api/algorithms");
const response = await fetch(
`${import.meta.env.VITE_API_URL}/algorithms`
);

if (!response.ok) {
throw new Error("Network response was not ok");
}
Expand Down Expand Up @@ -213,13 +216,16 @@ function App() {
setSelectedAlgorithmDetails(tempSelectedAlgorithmDetails);

try {
const response = await fetch("http://localhost:8000/api/evaluate/", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ a, b, k }),
});
const response = await fetch(
`${import.meta.env.VITE_API_URL}/evaluate/`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ a, b, k }),
}
);

if (!response.ok) {
throw new Error("Network response was not ok");
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Evaluate Master Theorem</title>
<script type="module" crossorigin src="/static/assets/index--18X3qIR.js"></script>
<script type="module" crossorigin src="/static/assets/index-HE6f1_nl.js"></script>
<link rel="stylesheet" crossorigin href="/static/assets/index-yX_c453z.css">
</head>

Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion staticfiles/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Evaluate Master Theorem</title>
<script type="module" crossorigin src="/static/assets/index--18X3qIR.js"></script>
<script type="module" crossorigin src="/static/assets/index-HE6f1_nl.js"></script>
<link rel="stylesheet" crossorigin href="/static/assets/index-yX_c453z.css">
</head>

Expand Down

0 comments on commit bb6c7f1

Please sign in to comment.