diff --git a/astro.config.mjs b/astro.config.mjs index 5d4cd39..8022c69 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -4,12 +4,11 @@ import cloudflare from "@astrojs/cloudflare"; import tailwindcss from "@tailwindcss/vite"; import react from "@astrojs/react"; +const base = process.env.BASE_URL || "/"; + // https://astro.build/config export default defineConfig({ - base: "/app", - build: { - assetsPrefix: "/app", - }, + base, security: { checkOrigin: false, }, @@ -33,4 +32,4 @@ export default defineConfig({ : undefined, }, }, -}); +}); \ No newline at end of file diff --git a/src/components/FileUploader.tsx b/src/components/FileUploader.tsx index 950e36c..2cf87ce 100644 --- a/src/components/FileUploader.tsx +++ b/src/components/FileUploader.tsx @@ -70,7 +70,7 @@ export default function FileUploader() { const loadFiles = async () => { try { setLoading(true); - const response = await fetch(`${import.meta.env.BASE_URL}/api/list-assets`); + const response = await fetch(`${import.meta.env.BASE_URL}api/list-assets`); if (!response.ok) { throw new Error("Failed to load files"); @@ -119,7 +119,7 @@ export default function FileUploader() { formData.append("file", file); - const response = await fetch(`${import.meta.env.BASE_URL}/api/upload`, { + const response = await fetch(`${import.meta.env.BASE_URL}api/upload`, { method: "POST", body: formData, }); @@ -154,8 +154,7 @@ export default function FileUploader() { setProgress(0); try { - const assetsPrefix = import.meta.env.ASSETS_PREFIX || ""; - const BASE_CF_URL = `${assetsPrefix}/api/multipart-upload`; + const BASE_CF_URL = `${import.meta.env.BASE_URL}api/multipart-upload`; const key = file.name; const CHUNK_SIZE = 5 * 1024 * 1024; // 5MB const totalParts = Math.ceil(file.size / CHUNK_SIZE); @@ -527,7 +526,7 @@ export default function FileUploader() { const fileLink = file.link || (file.key - ? `${import.meta.env.ASSETS_PREFIX}/api/asset?key=${file.key}` + ? `${import.meta.env.BASE_URL}api/asset?key=${file.key}` : ""); const uploadDate = file.dateUploaded || file.uploaded || new Date().toISOString(); @@ -636,6 +635,14 @@ export default function FileUploader() { )} +
+ Environment variables: + +