ref(frontend): add ~/const path

This commit is contained in:
이강준
2022-11-27 16:12:25 +09:00
parent 2729b409e6
commit 66d2a2724e
59 changed files with 1077 additions and 1086 deletions
+18 -18
View File
@@ -1,28 +1,28 @@
import token from "~/pages/api/auth/Token";
import { PATH } from "../../const";
import { PATH } from "~/const";
export default class SecurityClient {
static authOrigins = [PATH];
static #token = "";
static authOrigins = [PATH];
static #token = "";
contructor() {}
contructor() {}
static setToken(token) {
this.#token = token;
}
static setToken(token) {
this.#token = token;
}
static async fetchCall(resource, options) {
let req = new Request(resource, options);
const destOrigin = new URL(req.url).origin;
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.setToken(await token());
}
if (this.#token && this.authOrigins.includes(destOrigin)) {
req.headers.set("Authorization", "Bearer " + this.#token);
return fetch(req);
}
}
if (this.#token && this.authOrigins.includes(destOrigin)) {
req.headers.set("Authorization", "Bearer " + this.#token);
return fetch(req);
}
}
}