From 1d9eb66cab730c477cfb4dc6a4e9a768f66fc772 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Mar 2026 13:49:53 +0000 Subject: [PATCH 1/3] Initial plan From f1c7b8e4a19d3467a9efd47dafc8ccd5b342a074 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Mar 2026 13:55:49 +0000 Subject: [PATCH 2/3] chore: outline plan for CORS fix via server-side proxy Co-authored-by: TheRealSeber <111927572+TheRealSeber@users.noreply.github.com> --- project.inlang/.gitignore | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/project.inlang/.gitignore b/project.inlang/.gitignore index 06cf653..04df330 100644 --- a/project.inlang/.gitignore +++ b/project.inlang/.gitignore @@ -1 +1,19 @@ -cache +# IF GIT SHOWED THAT THIS FILE CHANGED +# +# 1. RUN THE FOLLOWING COMMAND +# +# --- +# git rm --cached '**/*.inlang/.gitignore' +# --- +# +# 2. COMMIT THE CHANGE +# +# --- +# git commit -m "fix: remove tracked .gitignore from inlang project" +# --- +# +# Inlang handles the gitignore itself starting with version ^2.5. +# +# everything is ignored except settings.json +* +!settings.json \ No newline at end of file From aa52e1a35eddbd71f8973a0ae319e69ba83a66dc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Mar 2026 13:59:26 +0000 Subject: [PATCH 3/3] fix: add server-side proxy to resolve CORS error in submission file preview Co-authored-by: TheRealSeber <111927572+TheRealSeber@users.noreply.github.com> --- src/routes/api/file-proxy/+server.ts | 44 +++++++++++++++++++ .../submissions/[submissionId]/+page.svelte | 3 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/routes/api/file-proxy/+server.ts diff --git a/src/routes/api/file-proxy/+server.ts b/src/routes/api/file-proxy/+server.ts new file mode 100644 index 0000000..0237f25 --- /dev/null +++ b/src/routes/api/file-proxy/+server.ts @@ -0,0 +1,44 @@ +import { env } from '$env/dynamic/private'; +import { error } from '@sveltejs/kit'; +import type { RequestHandler } from './$types'; + +export const GET: RequestHandler = async ({ url }) => { + const fileUrl = url.searchParams.get('url'); + + if (!fileUrl) { + throw error(400, 'Missing url parameter'); + } + + const fileStorageUrl = env.FILE_STORAGE_URL; + + if (!fileStorageUrl) { + throw error(500, 'File storage URL not configured'); + } + + if (!fileUrl.startsWith(fileStorageUrl)) { + throw error(403, 'URL not allowed'); + } + + let response: Response; + try { + response = await fetch(fileUrl); + } catch { + throw error(502, 'Failed to connect to file storage'); + } + + if (!response.ok) { + throw error( + response.status, + `Failed to fetch file from storage: ${response.status} ${response.statusText}` + ); + } + + const contentType = response.headers.get('Content-Type') ?? 'application/octet-stream'; + const body = await response.arrayBuffer(); + + return new Response(body, { + headers: { + 'Content-Type': contentType + } + }); +}; diff --git a/src/routes/dashboard/user/submissions/[submissionId]/+page.svelte b/src/routes/dashboard/user/submissions/[submissionId]/+page.svelte index c8162d3..e1e5473 100644 --- a/src/routes/dashboard/user/submissions/[submissionId]/+page.svelte +++ b/src/routes/dashboard/user/submissions/[submissionId]/+page.svelte @@ -44,7 +44,8 @@ let active = true; (async () => { try { - const response = await fetch(url); + const proxyUrl = `/api/file-proxy?url=${encodeURIComponent(url)}`; + const response = await fetch(proxyUrl); if (!response.ok) { fileContent = ''; return;