Add temporary brand field fix and deployment script

- Add empty brand field to API requests until server is updated
- Create deployment script for updating API server
- This fixes the 500 error when adding/editing filaments
This commit is contained in:
DaX
2025-06-27 01:52:02 +02:00
parent 06025623ff
commit d5ddb5f3df
2 changed files with 43 additions and 2 deletions

39
scripts/deploy-api.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/bin/bash
# Simple deployment script for API server
# This updates the API server code on EC2
API_SERVER_IP="3.71.161.51"
API_SERVER_URL="https://api.filamenteka.rs"
echo "🚀 Deploying API server updates..."
# Create a temporary deployment package
echo "📦 Creating deployment package..."
mkdir -p tmp-deploy
cp -r api/* tmp-deploy/
cp package.json tmp-deploy/
cp package-lock.json tmp-deploy/
# Create tarball
tar -czf api-deploy.tar.gz -C tmp-deploy .
rm -rf tmp-deploy
echo "📤 Package created: api-deploy.tar.gz"
echo ""
echo "⚠️ Manual deployment required:"
echo "1. Copy api-deploy.tar.gz to your server"
echo "2. SSH into the server at $API_SERVER_IP"
echo "3. Extract and restart the API service:"
echo " tar -xzf api-deploy.tar.gz"
echo " npm install --production"
echo " sudo systemctl restart node-api"
echo ""
echo "4. Run database migration if needed:"
echo " psql -U filamenteka_admin -d filamenteka < database/migrations/004_remove_brand_column.sql"
# Cleanup
rm -f api-deploy.tar.gz
echo ""
echo "✅ Deployment package instructions complete!"

View File

@@ -81,7 +81,8 @@ export const filamentService = {
// Transform bojaHex to boja_hex for backend // Transform bojaHex to boja_hex for backend
const data = { const data = {
...filament, ...filament,
boja_hex: filament.bojaHex || filament.boja_hex boja_hex: filament.bojaHex || filament.boja_hex,
brand: '' // Temporary fix until server is updated
}; };
delete data.bojaHex; // Remove the frontend field delete data.bojaHex; // Remove the frontend field
const response = await api.post('/filaments', data); const response = await api.post('/filaments', data);
@@ -92,7 +93,8 @@ export const filamentService = {
// Transform bojaHex to boja_hex for backend // Transform bojaHex to boja_hex for backend
const data = { const data = {
...filament, ...filament,
boja_hex: filament.bojaHex || filament.boja_hex boja_hex: filament.bojaHex || filament.boja_hex,
brand: filament.brand || '' // Temporary fix until server is updated
}; };
delete data.bojaHex; // Remove the frontend field delete data.bojaHex; // Remove the frontend field
const response = await api.put(`/filaments/${id}`, data); const response = await api.put(`/filaments/${id}`, data);