Next.js API route error in prod

so, basically I have an API route which throws error (500) only in prod, it works fine on dev server, I even built the app locally but it works just fine. Code -
import type { NextRequest } from "next/server";
import { getAnalytics } from "../../lib/umami";

export const config = {
runtime: "experimental-edge",
};

type UmamiResponse = {
pageviews: {
value: number;
};
uniques: {
value: number;
};
};

export default async function handler(req: NextRequest) {
const resp = await getAnalytics();
const analytics = (await resp.json()) as UmamiResponse;

return new Response(JSON.stringify(analytics), {
status: 200,
headers: {
"Content-Type": "application/json",
"cache-control": "public, s-maxage=60, stale-while-revalidate=30",
},
});
}
import type { NextRequest } from "next/server";
import { getAnalytics } from "../../lib/umami";

export const config = {
runtime: "experimental-edge",
};

type UmamiResponse = {
pageviews: {
value: number;
};
uniques: {
value: number;
};
};

export default async function handler(req: NextRequest) {
const resp = await getAnalytics();
const analytics = (await resp.json()) as UmamiResponse;

return new Response(JSON.stringify(analytics), {
status: 200,
headers: {
"Content-Type": "application/json",
"cache-control": "public, s-maxage=60, stale-while-revalidate=30",
},
});
}
3 Replies
asheeshh
asheeshhOP3y ago
the error
asheeshh
asheeshhOP3y ago
asheeshh
asheeshhOP3y ago
never mind, it got solved once i changed it to a normal api route,
Want results from more Discord servers?
Add your server