-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to set and clear token headers from front end
- Loading branch information
1 parent
96e679e
commit fb0b3ff
Showing
4 changed files
with
20 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
export * from "./openapi"; | ||
export { DefaultService as Backend } from "./openapi"; | ||
import { OpenAPI } from "./openapi"; | ||
import Cookies from "js-cookie"; | ||
|
||
export const BACKEND_URL = "http://localhost:8000"; | ||
OpenAPI.BASE = BACKEND_URL; | ||
|
||
// Sets the token header to the stored authentication token from the cookie | ||
export function setToken() { | ||
console.log("Setting Token") | ||
OpenAPI.TOKEN = Cookies.get("auth") | ||
} | ||
|
||
// Sets the token header to nothing. | ||
export function clearToken() { | ||
console.log("Clearing token.") | ||
OpenAPI.TOKEN = undefined | ||
} |
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 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