I-36 Remove dependency to PATH const

This commit is contained in:
Reginald Bondoc
2022-11-30 23:39:23 +01:00
parent f9bf418bf8
commit d8aa5b5ff4
57 changed files with 54 additions and 125 deletions
@@ -1,8 +1,6 @@
import { PATH } from "~/const";
import token from "~/pages/api/auth/Token";
export default class SecurityClient {
static authOrigins = [PATH];
static #token = "";
contructor() {}
@@ -13,13 +11,12 @@ export default class SecurityClient {
static async fetchCall(resource, options) {
let req = new Request(resource, options);
const destOrigin = new URL(req.url).origin;
if (this.#token == "") {
this.setToken(await token());
}
if (this.#token && this.authOrigins.includes(destOrigin)) {
if (this.#token) {
req.headers.set("Authorization", "Bearer " + this.#token);
return fetch(req);
}