fix(website): edge-config fallback

This commit is contained in:
iCrawl
2023-04-02 18:30:00 +02:00
parent 6aba9e99eb
commit 0645bf0f7f
2 changed files with 26 additions and 22 deletions

View File

@@ -5,6 +5,7 @@ import type { ServerRuntime } from 'next/types';
export const runtime: ServerRuntime = 'edge'; export const runtime: ServerRuntime = 'edge';
export async function GET() { export async function GET() {
try {
const url = await get<string>('DISCORD_WEBHOOK_URL'); const url = await get<string>('DISCORD_WEBHOOK_URL');
const imageUrl = await get<string>('IT_IS_WEDNESDAY_MY_DUDES'); const imageUrl = await get<string>('IT_IS_WEDNESDAY_MY_DUDES');
if (url && imageUrl) { if (url && imageUrl) {
@@ -23,6 +24,7 @@ export async function GET() {
}), }),
}); });
} }
} catch {}
return NextResponse.json({ message: 'It is wednesday, my dudes' }); return NextResponse.json({ message: 'It is wednesday, my dudes' });
} }

View File

@@ -11,11 +11,13 @@ async function fetchLatestVersion(packageName: string) {
export default async function middleware(request: NextRequest) { export default async function middleware(request: NextRequest) {
if (request.nextUrl.pathname === '/docs') { if (request.nextUrl.pathname === '/docs') {
try {
const skip = await get<boolean>('SKIP_PACKAGE_VERSION_SELECTION'); const skip = await get<boolean>('SKIP_PACKAGE_VERSION_SELECTION');
if (skip) { if (skip) {
const latestVersion = await fetchLatestVersion('builders'); const latestVersion = await fetchLatestVersion('builders');
return NextResponse.redirect(new URL(`/docs/packages/builders/${latestVersion}`, request.url)); return NextResponse.redirect(new URL(`/docs/packages/builders/${latestVersion}`, request.url));
} }
} catch {}
} }
if (request.nextUrl.pathname.includes('discord.js')) { if (request.nextUrl.pathname.includes('discord.js')) {