Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/api/prod/constant.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import axios from 'axios';
import config from '../../config.json';

// SSR goes through internal API domain to avoid Cloudflare limitations
const baseURL = import.meta.env.SSR ? (process.env.INTERNAL_API_DOMAIN ?? config.apiDomain) : config.apiDomain;

const axiosInstance = axios.create({
baseURL: config.apiDomain,
baseURL,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
Expand Down
9 changes: 7 additions & 2 deletions src/routes/gene.$geneId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@ export async function loader({ params, request }) {
requestUrl: request.url.replace(/^https?:\/\/.+?\//, `${config.genericDomain}/`),
};
} catch (error: any) {
// console.error('Error loading gene data:', error);
throw new Response(error.data?.message || error.message || 'Gene not found', { status: 404 });
const status = error?.response?.status ?? error?.status;
if (status === 404 || (typeof status === 'number' && status >= 400 && status < 500)) {
throw new Response(error.data?.message || error.message || 'Gene not found', { status: 404 });
}
// Handle non 404 errors (e.g. network issues, server errors)
console.error('Gene loader API failure:', params.geneId, status ?? '', error?.message);
throw new Response('Upstream error while loading gene data', { status: 502 });
}
}

Expand Down
Loading