mirror of
https://github.com/umami-software/umami.git
synced 2026-02-16 18:45:36 +01:00
Replaced server action with api route.
This commit is contained in:
parent
93e71d900f
commit
2a559aa661
2 changed files with 27 additions and 17 deletions
|
|
@ -1,19 +1,14 @@
|
||||||
'use server';
|
import { parseRequest } from '@/lib/request';
|
||||||
|
import { json } from '@/lib/response';
|
||||||
|
|
||||||
export type Config = {
|
export async function GET(request: Request) {
|
||||||
cloudMode: boolean;
|
const { error } = await parseRequest(request, null, { skipAuth: true });
|
||||||
cloudUrl?: string;
|
|
||||||
faviconUrl?: string;
|
|
||||||
linksUrl?: string;
|
|
||||||
pixelsUrl?: string;
|
|
||||||
privateMode: boolean;
|
|
||||||
telemetryDisabled: boolean;
|
|
||||||
trackerScriptName?: string;
|
|
||||||
updatesDisabled: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function getConfig(): Promise<Config> {
|
if (error) {
|
||||||
return {
|
return error();
|
||||||
|
}
|
||||||
|
|
||||||
|
return json({
|
||||||
cloudMode: !!process.env.CLOUD_URL,
|
cloudMode: !!process.env.CLOUD_URL,
|
||||||
cloudUrl: process.env.CLOUD_URL,
|
cloudUrl: process.env.CLOUD_URL,
|
||||||
faviconUrl: process.env.FAVICON_URL,
|
faviconUrl: process.env.FAVICON_URL,
|
||||||
|
|
@ -23,5 +18,5 @@ export async function getConfig(): Promise<Config> {
|
||||||
telemetryDisabled: !!process.env.DISABLE_TELEMETRY,
|
telemetryDisabled: !!process.env.DISABLE_TELEMETRY,
|
||||||
trackerScriptName: process.env.TRACKER_SCRIPT_NAME,
|
trackerScriptName: process.env.TRACKER_SCRIPT_NAME,
|
||||||
updatesDisabled: !!process.env.DISABLE_UPDATES,
|
updatesDisabled: !!process.env.DISABLE_UPDATES,
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1,12 +1,27 @@
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useApp, setConfig } from '@/store/app';
|
import { useApp, setConfig } from '@/store/app';
|
||||||
import { getConfig, Config } from '@/app/actions/getConfig';
|
import { useApi } from '@/components/hooks/useApi';
|
||||||
|
|
||||||
|
export type Config = {
|
||||||
|
cloudMode: boolean;
|
||||||
|
cloudUrl?: string;
|
||||||
|
faviconUrl?: string;
|
||||||
|
linksUrl?: string;
|
||||||
|
pixelsUrl?: string;
|
||||||
|
privateMode: boolean;
|
||||||
|
telemetryDisabled: boolean;
|
||||||
|
trackerScriptName?: string;
|
||||||
|
updatesDisabled: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
export function useConfig(): Config {
|
export function useConfig(): Config {
|
||||||
const { config } = useApp();
|
const { config } = useApp();
|
||||||
|
const { get } = useApi();
|
||||||
|
|
||||||
async function loadConfig() {
|
async function loadConfig() {
|
||||||
setConfig(await getConfig());
|
const { data } = await get(`/config`);
|
||||||
|
|
||||||
|
setConfig(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue