fix: profile photo upload field name mismatch ('file'→'photo'), sitemap auto-run only on CLI
This commit is contained in:
@@ -72,7 +72,7 @@ export function ProfilePhotoUpload({ currentImage, userName, userId }: ProfilePh
|
||||
setPreviewUrl(objectUrl)
|
||||
|
||||
const formData = new FormData()
|
||||
formData.append("file", file)
|
||||
formData.append("photo", file)
|
||||
|
||||
try {
|
||||
const res = await fetch("/api/user/profile-photo", {
|
||||
@@ -86,8 +86,8 @@ export function ProfilePhotoUpload({ currentImage, userName, userId }: ProfilePh
|
||||
}
|
||||
|
||||
const data = await res.json()
|
||||
if (data.imageUrl) {
|
||||
setPreviewUrl(data.imageUrl)
|
||||
if (data.url) {
|
||||
setPreviewUrl(data.url)
|
||||
cleanupTempUrl()
|
||||
}
|
||||
setUploadState("success")
|
||||
|
||||
@@ -166,10 +166,13 @@ async function generateSitemaps() {
|
||||
console.log(`Sitemaps generated successfully! Total URLs: ${staticEntries.length + allDynamicEntries.length}`)
|
||||
}
|
||||
|
||||
// Run if called directly
|
||||
// Run if called directly (CLI execution, not module import)
|
||||
const isCliRun = typeof process !== "undefined" && process.argv?.[1]?.includes("generate-static")
|
||||
if (isCliRun) {
|
||||
generateSitemaps().catch((err) => {
|
||||
console.error("Failed to generate sitemaps:", err)
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
export { generateSitemaps }
|
||||
Reference in New Issue
Block a user