mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix: can't use node internals on edge
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
/* eslint-disable react/no-unknown-property */
|
/* eslint-disable react/no-unknown-property */
|
||||||
import { ImageResponse } from 'next/og';
|
import { ImageResponse } from 'next/og';
|
||||||
import { fetchNode } from '~/util/fetchNode';
|
|
||||||
import { resolveKind } from '~/util/resolveNodeKind';
|
import { resolveKind } from '~/util/resolveNodeKind';
|
||||||
|
|
||||||
export const runtime = 'edge';
|
export const runtime = 'edge';
|
||||||
@@ -17,7 +16,14 @@ export default async function Image({
|
|||||||
}: {
|
}: {
|
||||||
readonly params: { readonly item: string; readonly packageName: string; readonly version: string };
|
readonly params: { readonly item: string; readonly packageName: string; readonly version: string };
|
||||||
}) {
|
}) {
|
||||||
const node = await fetchNode({ item: params.item, packageName: params.packageName, version: params.version });
|
const normalizeItem = params.item.split(encodeURIComponent(':')).join('.').toLowerCase();
|
||||||
|
|
||||||
|
const isMainVersion = params.version === 'main';
|
||||||
|
const fileContent = await fetch(
|
||||||
|
`${process.env.BLOB_STORAGE_URL}/rewrite/${params.packageName}/${params.version}.${normalizeItem}.api.json`,
|
||||||
|
{ next: isMainVersion ? { revalidate: 0 } : { revalidate: 604_800 } },
|
||||||
|
);
|
||||||
|
const node = await fileContent.json();
|
||||||
|
|
||||||
return new ImageResponse(
|
return new ImageResponse(
|
||||||
(
|
(
|
||||||
|
|||||||
Reference in New Issue
Block a user