Use env variable for max file size limit

- Frontend: read VITE_MAX_FILE_SIZE_MB from env
- Update .env.example files with limits

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-12 17:13:30 +03:00
parent 44980454bb
commit 9d4b8dacd2
3 changed files with 12 additions and 4 deletions

View File

@@ -1,2 +1,3 @@
VITE_API_URL=http://localhost:4001
VITE_WS_URL=ws://localhost:4001
VITE_MAX_FILE_SIZE_MB=10

View File

@@ -1,7 +1,7 @@
<template>
<form @submit.prevent="handleUpload" class="upload-form">
<div class="form-group">
<label>MP3 файл (макс. 10MB)</label>
<label>MP3 файл (макс. {{ maxFileSizeMb }}MB)</label>
<input
type="file"
accept="audio/mpeg,audio/mp3"
@@ -34,6 +34,9 @@ const emit = defineEmits(['uploaded'])
const tracksStore = useTracksStore()
const maxFileSizeMb = import.meta.env.VITE_MAX_FILE_SIZE_MB || 10
const maxFileSize = maxFileSizeMb * 1024 * 1024
const title = ref('')
const artist = ref('')
const file = ref(null)
@@ -45,9 +48,9 @@ function handleFileSelect(e) {
const selectedFile = e.target.files[0]
if (!selectedFile) return
// Check file size (10MB)
if (selectedFile.size > 10 * 1024 * 1024) {
error.value = 'Файл слишком большой (макс. 10MB)'
// Check file size
if (selectedFile.size > maxFileSize) {
error.value = `Файл слишком большой (макс. ${maxFileSizeMb}MB)`
fileInput.value.value = ''
return
}