fix: 修复my_oss API路径,添加/api前缀
This commit is contained in:
@@ -62,7 +62,7 @@ export async function POST(request: NextRequest) {
|
|||||||
const blob = new Blob([uint8Array], { type: 'image/jpeg' });
|
const blob = new Blob([uint8Array], { type: 'image/jpeg' });
|
||||||
formData2.append('file', blob, 'image.jpg');
|
formData2.append('file', blob, 'image.jpg');
|
||||||
|
|
||||||
const uploadRes = await fetch(`${OSS_URL}/files`, {
|
const uploadRes = await fetch(`${OSS_URL}/api/files`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'x-api-key': API_KEY,
|
'x-api-key': API_KEY,
|
||||||
@@ -79,7 +79,7 @@ export async function POST(request: NextRequest) {
|
|||||||
const fileData = await uploadRes.json();
|
const fileData = await uploadRes.json();
|
||||||
|
|
||||||
// 返回 my_oss 的访问URL
|
// 返回 my_oss 的访问URL
|
||||||
const url = `${OSS_URL}/files/${fileData.fileKey}/preview`;
|
const url = `${OSS_URL}/api/files/${fileData.fileKey}/preview`;
|
||||||
return NextResponse.json({ url, fileKey: fileData.fileKey });
|
return NextResponse.json({ url, fileKey: fileData.fileKey });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Upload error:', error);
|
console.error('Upload error:', error);
|
||||||
@@ -96,7 +96,7 @@ export async function DELETE(request: NextRequest) {
|
|||||||
return NextResponse.json({ error: '缺少文件标识' }, { status: 400 });
|
return NextResponse.json({ error: '缺少文件标识' }, { status: 400 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await fetch(`${OSS_URL}/files/${fileKey}`, {
|
const res = await fetch(`${OSS_URL}/api/files/${fileKey}`, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: {
|
headers: {
|
||||||
'x-api-key': API_KEY,
|
'x-api-key': API_KEY,
|
||||||
|
|||||||
Reference in New Issue
Block a user