Migrace sestavování klienta na Vite
This commit is contained in:
@@ -1,15 +1,3 @@
|
||||
/**
|
||||
* Vrátí kořenovou URL serveru na základě aktuálního prostředí (vývojovou či produkční).
|
||||
*
|
||||
* @returns kořenová URL serveru
|
||||
*/
|
||||
export const getBaseUrl = (): string => {
|
||||
if (process.env.PUBLIC_URL) {
|
||||
return process.env.PUBLIC_URL;
|
||||
}
|
||||
return 'http://127.0.0.1:3001';
|
||||
}
|
||||
|
||||
const TOKEN_KEY = "token";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { toast } from "react-toastify";
|
||||
import { getBaseUrl, getToken } from "../Utils";
|
||||
import { getToken } from "../Utils";
|
||||
|
||||
/**
|
||||
* Wrapper pro volání API, u kterých chceme automaticky zobrazit toaster s chybou ze serveru.
|
||||
@@ -23,7 +23,7 @@ async function request<TResponse>(
|
||||
config.headers = config?.headers ? new Headers(config.headers) : new Headers();
|
||||
config.headers.set("Authorization", `Bearer ${getToken()}`);
|
||||
try {
|
||||
const response = await fetch(getBaseUrl() + url, config);
|
||||
const response = await fetch(url, config);
|
||||
if (!response.ok) {
|
||||
// TODO tohle je blbě, jelikož automaticky očekáváme, že v případě chyby přijde vždy JSON, což není pravda
|
||||
const json = await response.json();
|
||||
@@ -48,7 +48,7 @@ async function blobRequest(
|
||||
config.headers = config?.headers ? new Headers(config.headers) : new Headers();
|
||||
config.headers.set("Authorization", `Bearer ${getToken()}`);
|
||||
try {
|
||||
const response = await fetch(getBaseUrl() + url, config);
|
||||
const response = await fetch(url, config);
|
||||
if (!response.ok) {
|
||||
const json = await response.json();
|
||||
// Vyhodíme samotnou hlášku z odpovědi, odchytí si jí errorHandler
|
||||
@@ -67,7 +67,7 @@ export const api = {
|
||||
}
|
||||
|
||||
export const getQrUrl = (login: string) => {
|
||||
return `${getBaseUrl()}/api/qr?login=${login}`;
|
||||
return `/api/qr?login=${login}`;
|
||||
}
|
||||
|
||||
export const getData = async (dayIndex?: number) => {
|
||||
|
||||
1
client/src/react-app-env.d.ts
vendored
1
client/src/react-app-env.d.ts
vendored
@@ -1 +0,0 @@
|
||||
/// <reference types="react-scripts" />
|
||||
Reference in New Issue
Block a user