Skip to content

Commit

Permalink
Update route.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi authored Aug 11, 2023
1 parent a148d0b commit 6e8b261
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ async function resolveNotFound(request: Request): Promise<Response> {
if (fallback === 'true') {
const baseURI = (process.env.NEXT_PUBLIC_VERCEL_URL ? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}` : (request as any)?.nextUrl?.origin);
const result = await fetch(`${baseURI}/not-found.png`);
return new Response(result.body, {headers: {'Content-Type': 'image/png', 'Cache-Control': 'public, max-age=86400'}});
return new Response(result.body, {headers: {'Content-Type': 'image/png', 'Cache-Control': 'public, max-age=86400, must-revalidate'}});
}

if (fallback) {
const result = await fetch(fallback);
const contentTypeFromFallback = result.headers.get('Content-Type');
if (contentTypeFromFallback?.startsWith('image/')) {
console.warn(`Using fallback image for gas token: ${fallback}`);
return new Response(result.body, {headers: {'Content-Type': contentTypeFromFallback, 'Cache-Control': 'public, max-age=86400'}});
return new Response(result.body, {headers: {'Content-Type': contentTypeFromFallback, 'Cache-Control': 'public, max-age=86400, must-revalidate'}});
}
}
return new Response('Not found', {status: 404});
Expand All @@ -30,14 +30,14 @@ async function resolveGasToken(request: Request): Promise<Response> {
if (fallback === 'true') {
const baseURI = (process.env.NEXT_PUBLIC_VERCEL_URL ? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}` : (request as any)?.nextUrl?.origin);
const result = await fetch(`${baseURI}/gas-token.png`);
return new Response(result.body, {headers: {'Content-Type': 'image/png', 'Cache-Control': 'public, max-age=86400'}});
return new Response(result.body, {headers: {'Content-Type': 'image/png', 'Cache-Control': 'public, max-age=86400, must-revalidate'}});
}
if (fallback) {
const result = await fetch(fallback);
const contentTypeFromFallback = result.headers.get('Content-Type');
if (contentTypeFromFallback?.startsWith('image/')) {
console.warn(`Using fallback image for gas token: ${fallback}`);
return new Response(result.body, {headers: {'Content-Type': contentTypeFromFallback, 'Cache-Control': 'public, max-age=86400'}});
return new Response(result.body, {headers: {'Content-Type': contentTypeFromFallback, 'Cache-Control': 'public, max-age=86400, must-revalidate'}});
}
}
return new Response('Not found', {status: 404});
Expand All @@ -58,9 +58,9 @@ export async function GET(request: Request, context: TContext): Promise<Response
const result = await fetch(`${baseURI}/${chainIDStr}/${tokenAddress}/${fileName}`);
if (result.ok) {
if (fileName.endsWith('.svg')) {
return new Response(result.body, {headers: {'Content-Type': 'image/svg+xml', 'Cache-Control': 'public, max-age=86400'}});
return new Response(result.body, {headers: {'Content-Type': 'image/svg+xml', 'Cache-Control': 'public, max-age=86400, must-revalidate'}});
}
return new Response(result.body, {headers: {'Content-Type': 'image/png', 'Cache-Control': 'public, max-age=86400'}});
return new Response(result.body, {headers: {'Content-Type': 'image/png', 'Cache-Control': 'public, max-age=86400, must-revalidate'}});
}

if (tokenAddress === '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee') {
Expand Down

1 comment on commit 6e8b261

@vercel
Copy link

@vercel vercel bot commented on 6e8b261 Aug 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.