1
0
Fork 0
forked from Kispi/Core

fix(webapp): servertime on production
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simon Giesel 2023-07-13 10:56:48 +02:00
parent c98b51c22a
commit d92696e2ff

View file

@ -1,6 +1,3 @@
import { PocketbaseService } from './pocketbase.service';
const API = PocketbaseService.getApi();
let serverTime: Date; let serverTime: Date;
export class DateService { export class DateService {
@ -40,7 +37,10 @@ export class DateService {
} }
public static async getServerTime(): Promise<Date> { public static async getServerTime(): Promise<Date> {
if(!serverTime || this.isOlderThanAMinute(serverTime)) { if(!serverTime || this.isOlderThanAMinute(serverTime)) {
serverTime = new Date(await (await fetch(API.baseUrl + '/api/time')).text()); serverTime = new Date(await (await fetch(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(import.meta as any).env.MODE === 'development' ? 'http://127.0.0.1:8090/api/time' : '/api/time',
)).text());
} }
return serverTime; return serverTime;
} }