Skip to content

An AI-powered search engine with a generative UI

Check authentication before upload storage config errors

Yoshiki Miura507b4cfe94df
diff --git a/app/api/upload/route.ts b/app/api/upload/route.ts
index fdbf7954..483e9bde 100644
--- a/app/api/upload/route.ts
+++ b/app/api/upload/route.ts
@@ -14,6 +14,11 @@ const ALLOWED_TYPES = ['image/jpeg', 'image/png', 'application/pdf']
export async function POST(req: NextRequest) {
try {
+ const userId = await getCurrentUserId()
+ if (!userId) {
+ return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
+ }
+
if (!isObjectStorageConfigured()) {
return NextResponse.json(
{
@@ -25,10 +30,6 @@ export async function POST(req: NextRequest) {
)
}
- const userId = await getCurrentUserId()
- if (!userId) {
- return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
- }
const contentType = req.headers.get('content-type') || ''
if (!contentType.includes('multipart/form-data')) {
return NextResponse.json(