fix(backend): Split public and protected routes to fix 401 errors

This commit is contained in:
goose 2026-02-15 15:44:01 -03:00
parent e5d0ae4fd1
commit 26f0df58ef
3 changed files with 138 additions and 6 deletions

53
backend/test-api-remote.sh Executable file
View file

@ -0,0 +1,53 @@
#!/bin/bash
# API Testing Script for Normogen Backend (Remote Server)
# Server is running at 10.0.10.30:6800
echo "🧪 Testing Normogen API Endpoints at http://10.0.10.30:6800"
echo "================================================================"
echo ""
# Test 1: Health Check
echo "1. Testing Health Check..."
HEALTH=$(curl -s -w "
HTTP Status: %{http_code}
" http://10.0.10.30:6800/health)
echo "$HEALTH"
echo ""
# Test 2: Ready Check
echo "2. Testing Ready Check..."
READY=$(curl -s -w "
HTTP Status: %{http_code}
" http://10.0.10.30:6800/ready)
echo "$READY"
echo ""
# Test 3: Register User
echo "3. Testing User Registration..."
REGISTER=$(curl -s -w "
HTTP Status: %{http_code}
" -X POST http://10.0.10.30:6800/api/auth/register \
-H "Content-Type: application/json" \
-d '{"email": "test@example.com", "password": "SecurePassword123!", "username": "testuser"}')
echo "$REGISTER"
echo ""
# Test 4: Login
echo "4. Testing User Login..."
LOGIN=$(curl -s -w "
HTTP Status: %{http_code}
" -X POST http://10.0.10.30:6800/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "test@example.com", "password": "SecurePassword123!"}')
echo "$LOGIN"
echo ""
# Test 5: Protected Endpoint (should fail without auth)
echo "5. Testing Protected Endpoint (without auth, should fail)..."
PROFILE=$(curl -s -w "
HTTP Status: %{http_code}
" http://10.0.10.30:6800/api/users/me)
echo "$PROFILE"
echo ""
echo "✅ Tests complete!"