mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 18:33:01 +00:00
SERVER_URL environment variable
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -23,3 +23,5 @@ dist-ssr
|
|||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
.vscode/extensions.json
|
.vscode/extensions.json
|
||||||
|
|
||||||
|
.env
|
||||||
16
src/Home.tsx
16
src/Home.tsx
@@ -1,5 +1,6 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { CloudSync, RefreshCw } from "lucide-react";
|
||||||
|
|
||||||
function Issue({ issue }: { issue: any }) {
|
function Issue({ issue }: { issue: any }) {
|
||||||
return (
|
return (
|
||||||
@@ -11,7 +12,8 @@ function Issue({ issue }: { issue: any }) {
|
|||||||
|
|
||||||
function Home() {
|
function Home() {
|
||||||
const [issues, setIssues] = useState([]);
|
const [issues, setIssues] = useState([]);
|
||||||
const [serverURL, setServerURL] = useState("http://localhost:3000");
|
|
||||||
|
const serverURL = import.meta.env.SERVER_URL?.trim() || "http://localhost:3000";
|
||||||
|
|
||||||
async function getIssues() {
|
async function getIssues() {
|
||||||
const res = await fetch(`${serverURL}/issues/all`);
|
const res = await fetch(`${serverURL}/issues/all`);
|
||||||
@@ -23,7 +25,17 @@ function Home() {
|
|||||||
<main className="w-full h-[100vh] flex flex-col items-center justify-center gap-4 p-4">
|
<main className="w-full h-[100vh] flex flex-col items-center justify-center gap-4 p-4">
|
||||||
<h1>Issue Project Manager</h1>
|
<h1>Issue Project Manager</h1>
|
||||||
<Button onClick={getIssues} className={""}>
|
<Button onClick={getIssues} className={""}>
|
||||||
{issues.length > 0 ? "re-fetch issues" : "fetch issues"}
|
{issues.length > 0 ? (
|
||||||
|
<>
|
||||||
|
re-fetch issues
|
||||||
|
<RefreshCw />
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
fetch issues
|
||||||
|
<CloudSync />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{issues.length > 0 && (
|
{issues.length > 0 && (
|
||||||
|
|||||||
10
src/vite-env.d.ts
vendored
10
src/vite-env.d.ts
vendored
@@ -1 +1,11 @@
|
|||||||
/// <reference types="vite/client" />
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
type ViteString = string | undefined;
|
||||||
|
|
||||||
|
interface ImportMetaEnv {
|
||||||
|
readonly SERVER_URL: ViteString;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImportMeta {
|
||||||
|
readonly env: ImportMetaEnv;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user