Backend GKE Deploy, access key for backend

- Configs and automation for deploying backend to GKE
- First steps to adding an optional token check for requests to backend
- First steps frontend sending optional token to backend when configured
This commit is contained in:
Hristo 2024-05-10 16:07:58 -04:00
parent 0fedaef537
commit e6c2042df6
17 changed files with 296 additions and 39 deletions

View file

@ -1,5 +1,6 @@
import clsx, { ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';
import { getAccessKey, getBackendURL } from './config'
export const cn = (...classes: ClassValue[]) => twMerge(clsx(...classes));
@ -19,3 +20,20 @@ export const formatTimeDifference = (date1: Date, date2: Date): string => {
else
return `${Math.floor(diffInSeconds / 31536000)} year${Math.floor(diffInSeconds / 31536000) !== 1 ? 's' : ''}`;
};
export const clientFetch = async (path: string, payload: any): Promise<any> => {
let headers = payload.headers;
const url = `${getBackendURL()}${path}`;
const secret_token = getAccessKey();
if (secret_token) {
if (headers == null) {
headers = {};
};
headers['Authorization'] = `Bearer ${secret_token}`;
payload.headers = headers;
};
return await fetch(url, payload);
};