mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-26 22:30:11 +00:00
* fix(dashboard): route dev API calls on Accept and fail fast on non-JSON 2xx The next dev rewrite that sends API calls to the proxy keyed on Content-Type: application/json, which openapi-fetch rightly omits on a bodyless GET, so GET /lens fell through to the Lens page and returned HTML. Route on Accept: application/json instead, send it from both HTTP clients, turn a non-JSON 2xx into a non-retryable ApiError in the typed client, and stop react-query from retrying ApiError below 500. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(dashboard): accept a JSON body served without a JSON content type Test fakes and some servers hand back JSON as text/plain, so the typed client only rejects a 2xx whose body does not parse as JSON. The system_one request test expects the Accept header the legacy client now sends. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Yujong Lee <yujong@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
53 lines
1.7 KiB
JavaScript
53 lines
1.7 KiB
JavaScript
import path from "path";
|
|
import { fileURLToPath } from "url";
|
|
|
|
/** @type {import('next').NextConfig} */
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
const devProxyUrl = process.env.LENS_DEV_PROXY_URL;
|
|
|
|
const nextConfig = {
|
|
...(devProxyUrl
|
|
? {
|
|
async rewrites() {
|
|
return {
|
|
beforeFiles: [
|
|
// Every dashboard HTTP client sends Accept: application/json; page loads and RSC
|
|
// fetches do not. That is what keeps GET /lens (API) apart from /lens (page) in dev.
|
|
{
|
|
source: "/:path*",
|
|
has: [{ type: "header", key: "accept", value: "application/json.*" }],
|
|
destination: `${devProxyUrl}/:path*`,
|
|
},
|
|
{ source: "/ui/:path*", destination: "/:path*" },
|
|
],
|
|
fallback: [{ source: "/:path*", destination: `${devProxyUrl}/:path*` }],
|
|
};
|
|
},
|
|
}
|
|
: {}),
|
|
output: devProxyUrl ? undefined : "export",
|
|
typescript: { tsconfigPath: "tsconfig.production.json" },
|
|
experimental: {
|
|
useTypeScriptCli: false,
|
|
},
|
|
compiler: {
|
|
removeConsole: process.env.NODE_ENV === "production" ? { exclude: ["error", "warn"] } : false,
|
|
},
|
|
// Required with output: "export" — default image optimizer runs only in server mode.
|
|
// See https://nextjs.org/docs/messages/export-image-api
|
|
images: {
|
|
unoptimized: true,
|
|
},
|
|
basePath: "",
|
|
assetPrefix: "/litellm-asset-prefix",
|
|
trailingSlash: !devProxyUrl,
|
|
skipTrailingSlashRedirect: Boolean(devProxyUrl),
|
|
turbopack: {
|
|
// Must be absolute; "." is no longer allowed
|
|
root: __dirname,
|
|
},
|
|
};
|
|
|
|
export default nextConfig;
|