Skip to content

Commit

Permalink
feature: add customization of timeout for backend's responses (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
MDeLuise authored Sep 10, 2023
1 parent b1b4477 commit cb23997
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ There are 2 configuration file available:
```
PORT=3000 # port that will serve the frontend, if on docker deployment leave as it is and change the port binding in the docker-compose file if needed
API_URL=http://localhost:8080/api
WAIT_TIMEOUT=5000 # timeout for backend responses (in milliseconds)
PAGE_SIZE=25
Expand Down
1 change: 1 addition & 0 deletions deployment/frontend.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PORT=3000
API_URL=http://localhost:8080/api
WAIT_TIMEOUT=5000

PAGE_SIZE=25

Expand Down
1 change: 1 addition & 0 deletions frontend/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
PORT=3000
API_URL=http://localhost:8085/api
WAIT_TIMEOUT=5000

PAGE_SIZE=25
3 changes: 2 additions & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ const ColorModeContext = React.createContext({ toggleColorMode: () => { } });
export function App() {
const isLoggedIn: () => boolean = () => secureLocalStorage.getItem("plant-it-key") != null;
const backendURL = window._env_.API_URL != null ? window._env_.API_URL : "http://localhost:8085/api";
const axiosTimeout = window._env_.WAIT_TIMEOUT != null ? window._env_.WAIT_TIMEOUT : 5000;
const axiosReq = axios.create({
baseURL: backendURL,
timeout: 5000
timeout: axiosTimeout,
});

axiosReq.interceptors.request.use(
Expand Down
1 change: 1 addition & 0 deletions frontend/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ declare global {
interface Window {
_env_: {
API_URL: string
WAIT_TIMEOUT: number | undefined
}
}
}
Expand Down

0 comments on commit cb23997

Please sign in to comment.