Skip to content

Commit d269b92

Browse files
committed
Bugfix: avatar upload throws 419
1 parent 24185dc commit d269b92

3 files changed

Lines changed: 7 additions & 19 deletions

File tree

.docker/scripts/staging.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ echo -e "${BLUE}📦 Installing PHP dependencies...${NC}"
5656
"$SCRIPTS_DIR/composer.sh" install --no-interaction --optimize-autoloader
5757

5858
# 8. Run migrations and seed
59-
echo -e "${BLUE}🗄️ Running database migrations and seeders...${NC}"
60-
"$SCRIPTS_DIR/artisan.sh" migrate:fresh --seed --force
59+
# echo -e "${BLUE}🗄️ Running database migrations and seeders...${NC}"
60+
# "$SCRIPTS_DIR/artisan.sh" migrate:fresh --seed --force
6161

6262
# 9. Create storage symlink
6363
echo -e "${BLUE}🔗 Creating storage symlink...${NC}"

app/Http/Controllers/Settings/AvatarController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ public function update(AvatarUpdateRequest $request): JsonResponse
1717

1818
$user->avatar && Storage::disk('public')->delete($user->avatar);
1919

20-
$user->update([
21-
'avatar' => $request->avatar->store('avatars', 'public'),
22-
]);
20+
$path = $request->avatar->store('avatars', 'public');
21+
22+
$user->update(['avatar' => $path]);
2323

2424
return response()->json([
2525
'message' => __('Avatar updated successfully!'),

resources/js/components/avatar/AvatarUpload.vue

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
33
import { Button } from '@/components/ui/button';
44
import { useInitials } from '@/composables/useInitials';
55
import { _ } from '@/composables/useTranslations';
6+
import axios from 'axios';
67
import { Camera, Loader2, X } from 'lucide-vue-next';
78
89
interface Props {
@@ -98,20 +99,7 @@ const uploadAvatar = async (file: File) => {
9899
formData.append('avatar', file);
99100
100101
try {
101-
const response = await fetch(route(props.uploadRoute), {
102-
method: 'POST',
103-
headers: {
104-
'X-CSRF-TOKEN':
105-
document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') || '',
106-
},
107-
body: formData,
108-
});
109-
110-
if (!response.ok) {
111-
throw new Error('Upload failed');
112-
}
113-
114-
const data = await response.json();
102+
const { data } = await axios.post(route(props.uploadRoute), formData);
115103
116104
emit('success', data.avatar_url);
117105
} catch (_error) {

0 commit comments

Comments
 (0)