generated from ctc-uci/npo-frontend-vite-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf8a2da
commit 343435a
Showing
4 changed files
with
38 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { createContext, useContext } from 'react'; | ||
import axios from 'axios'; | ||
|
||
// @ts-expect-error trust me bro | ||
const baseURL = import.meta.env.VITE_BACKEND_HOSTNAME; | ||
|
||
const BackendContext = createContext(null); | ||
const useBackend = () => useContext(BackendContext); | ||
|
||
const BackendProvider = ({ children }: { children: React.ReactNode }) => { | ||
const backend = axios.create({ | ||
baseURL, | ||
withCredentials: false, | ||
}); | ||
|
||
return <BackendContext.Provider value={{ backend }}>{children}</BackendContext.Provider>; | ||
}; | ||
|
||
export { BackendProvider, useBackend }; |