|
|
|
|
@ -275,7 +275,8 @@ function buildTargetUrl(baseUrl: string, apiPath: string, searchParams: URLSearc
@@ -275,7 +275,8 @@ function buildTargetUrl(baseUrl: string, apiPath: string, searchParams: URLSearc
|
|
|
|
|
export const GET: RequestHandler = async ({ params, url }) => { |
|
|
|
|
try { |
|
|
|
|
const baseUrl = url.searchParams.get('baseUrl'); |
|
|
|
|
const apiPath = params.path; |
|
|
|
|
// params.path might be a string or array depending on SvelteKit version
|
|
|
|
|
const apiPath = Array.isArray(params.path) ? params.path.join('/') : params.path; |
|
|
|
|
|
|
|
|
|
if (!baseUrl) { |
|
|
|
|
return createErrorResponse('Missing baseUrl query parameter', 400); |
|
|
|
|
@ -303,8 +304,26 @@ export const GET: RequestHandler = async ({ params, url }) => {
@@ -303,8 +304,26 @@ export const GET: RequestHandler = async ({ params, url }) => {
|
|
|
|
|
|
|
|
|
|
// Log error responses for debugging
|
|
|
|
|
if (!response.ok) { |
|
|
|
|
console.error('[Gitea Proxy] Error response:', response.status, response.statusText); |
|
|
|
|
console.error('[Gitea Proxy] Response body:', body.substring(0, 500)); |
|
|
|
|
// Skip logging 404s for README file requests - these are expected when trying multiple file extensions
|
|
|
|
|
const isReadmeRequest = apiPath.includes('contents') &&
|
|
|
|
|
(apiPath.toLowerCase().includes('readme') || apiPath.toLowerCase().includes('readme')); |
|
|
|
|
|
|
|
|
|
if (response.status === 404 && isReadmeRequest) { |
|
|
|
|
// Silently skip - expected when trying README.adoc, README.md, etc.
|
|
|
|
|
} else if (response.status === 404) { |
|
|
|
|
// Log other 404s with context
|
|
|
|
|
console.warn('[Gitea Proxy] 404 Not Found:', { |
|
|
|
|
apiPath, |
|
|
|
|
targetUrl, |
|
|
|
|
baseUrl, |
|
|
|
|
body: body.substring(0, 200) |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
// Log non-404 errors
|
|
|
|
|
console.error('[Gitea Proxy] Error response:', response.status, response.statusText); |
|
|
|
|
console.error('[Gitea Proxy] Request URL:', targetUrl); |
|
|
|
|
console.error('[Gitea Proxy] Response body:', body.substring(0, 500)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return new Response(body, { |
|
|
|
|
|