mirror of
https://github.com/civitai/civitai.git
synced 2026-09-20 22:08:18 +08:00
fix get blob data not working with civitai client cli
This commit is contained in:
+7
-2
@@ -3,8 +3,10 @@ import { withAxiom } from '@civitai/next-axiom';
|
||||
import bundlAnalyzer from '@next/bundle-analyzer';
|
||||
import packageJson from './package.json' assert { type: 'json' };
|
||||
|
||||
const analyze = process.env.ANALYZE === 'true';
|
||||
|
||||
const withBundleAnalyzer = bundlAnalyzer({
|
||||
enabled: process.env.ANALYZE === 'true',
|
||||
enabled: analyze,
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -63,7 +65,10 @@ export default defineNextConfig(
|
||||
experimental: {
|
||||
// scrollRestoration: true,
|
||||
largePageDataBytes: 512 * 100000,
|
||||
optimizePackageImports: ['@civitai/client', './srs/libs/form'],
|
||||
optimizePackageImports: [
|
||||
'@civitai/client',
|
||||
'./srs/libs/form'
|
||||
],
|
||||
},
|
||||
headers: async () => {
|
||||
// Add X-Robots-Tag header to all pages matching /sitemap.xml and /sitemap-models.xml /sitemap-articles.xml, etc
|
||||
|
||||
@@ -11,27 +11,41 @@ export const nsfwNsfwLevels: NSFWLevel[] = ['r', 'x', 'xxx'];
|
||||
export async function getBlobData({ token, blobId }: { token: string; blobId: string }) {
|
||||
const client = createOrchestratorClient(token);
|
||||
|
||||
const { error, response } = await headBlob({
|
||||
client,
|
||||
path: { blobId },
|
||||
}).catch((error) => {
|
||||
throw error;
|
||||
});
|
||||
if (error) {
|
||||
switch (error.status) {
|
||||
case 400:
|
||||
throw throwBadRequestError(error.detail);
|
||||
case 401:
|
||||
throw throwAuthorizationError(error.detail);
|
||||
console.log(client.getConfig().baseUrl);
|
||||
|
||||
default:
|
||||
if (error.detail?.startsWith('<!DOCTYPE'))
|
||||
throw throwInternalServerError('Generation services down');
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
const response = await fetch(`${client.getConfig().baseUrl}/v2/consumer/blobs/${blobId}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
if (!response.ok) throw new Error('unable to fetch blob data');
|
||||
|
||||
return {
|
||||
nsfwLevel: response.headers.get('x-nsfw-level')?.toLocaleLowerCase() as NSFWLevel | null,
|
||||
};
|
||||
|
||||
// const { error, data, response, request } = await headBlob({
|
||||
// client,
|
||||
// path: { blobId },
|
||||
// }).catch((error) => {
|
||||
// console.log('--------------------------');
|
||||
// throw error;
|
||||
// });
|
||||
// if (error) {
|
||||
// switch (error.status) {
|
||||
// case 400:
|
||||
// throw throwBadRequestError(error.detail);
|
||||
// case 401:
|
||||
// throw throwAuthorizationError(error.detail);
|
||||
|
||||
// default:
|
||||
// if (error.detail?.startsWith('<!DOCTYPE'))
|
||||
// throw throwInternalServerError('Generation services down');
|
||||
// throw error;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return {
|
||||
// nsfwLevel: response.headers.get('x-nsfw-level')?.toLocaleLowerCase() as NSFWLevel | null,
|
||||
// };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user