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:
parent
0fedaef537
commit
e6c2042df6
17 changed files with 296 additions and 39 deletions
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue