mirror of
https://github.com/Xevion/linkpulse.git
synced 2025-12-10 10:07:48 -06:00
Fixup backend URL target on frontend, devmode fast refresh
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
const backendUrl = `http://${import.meta.env.VITE_BACKEND_TARGET}/api`;
|
||||||
|
|
||||||
const Code = (props: JSX.IntrinsicElements['code']) => (
|
const Code = (props: JSX.IntrinsicElements['code']) => (
|
||||||
<code
|
<code
|
||||||
className="border-1 2py-1 rounded border border-pink-500 bg-neutral-100 px-1 font-mono font-light text-pink-500 dark:border-pink-400 dark:bg-neutral-700 dark:text-pink-400"
|
className="border-1 2py-1 rounded border border-pink-500 bg-neutral-100 px-1 font-mono font-light text-pink-500 dark:border-pink-400 dark:bg-neutral-700 dark:text-pink-400"
|
||||||
@@ -13,7 +15,7 @@ export default function App() {
|
|||||||
|
|
||||||
const refreshData = async () => {
|
const refreshData = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('');
|
const response = await fetch(`${backendUrl}/test`);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
const { time, ip } = data;
|
const { time, ip } = data;
|
||||||
|
|
||||||
@@ -30,7 +32,7 @@ export default function App() {
|
|||||||
|
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
refreshData();
|
refreshData();
|
||||||
}, 30 * 1000);
|
}, (import.meta.env.DEV ? 1 : 30) * 1000);
|
||||||
|
|
||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
Reference in New Issue
Block a user