Spaces:
Running
Running
Commit ·
0db865c
1
Parent(s): eec0edf
Add: Render deployment configuration with environment-aware API URL
Browse files- frontend/index.html +12 -1
- render.yaml +50 -0
frontend/index.html
CHANGED
|
@@ -222,6 +222,13 @@
|
|
| 222 |
</div>
|
| 223 |
|
| 224 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
const fileInput = document.getElementById('fileInput');
|
| 226 |
const loading = document.getElementById('loading');
|
| 227 |
const results = document.getElementById('results');
|
|
@@ -237,7 +244,11 @@
|
|
| 237 |
formData.append('file', file);
|
| 238 |
|
| 239 |
try {
|
| 240 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
method: 'POST',
|
| 242 |
body: formData
|
| 243 |
});
|
|
|
|
| 222 |
</div>
|
| 223 |
|
| 224 |
<script>
|
| 225 |
+
// Auto-detect API URL based on environment
|
| 226 |
+
const API_URL = window.location.hostname.includes('onrender.com')
|
| 227 |
+
? 'https://verifile-x-api.onrender.com'
|
| 228 |
+
: window.location.hostname === 'localhost'
|
| 229 |
+
? 'http://localhost:8000'
|
| 230 |
+
: ''; // Use relative URL for other environments
|
| 231 |
+
|
| 232 |
const fileInput = document.getElementById('fileInput');
|
| 233 |
const loading = document.getElementById('loading');
|
| 234 |
const results = document.getElementById('results');
|
|
|
|
| 244 |
formData.append('file', file);
|
| 245 |
|
| 246 |
try {
|
| 247 |
+
const apiEndpoint = API_URL
|
| 248 |
+
? `${API_URL}/api/v1/analyze/image`
|
| 249 |
+
: '/api/v1/analyze/image';
|
| 250 |
+
|
| 251 |
+
const response = await fetch(apiEndpoint, {
|
| 252 |
method: 'POST',
|
| 253 |
body: formData
|
| 254 |
});
|
render.yaml
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
services:
|
| 2 |
+
# Backend API Service
|
| 3 |
+
- type: web
|
| 4 |
+
name: verifile-x-api
|
| 5 |
+
runtime: python
|
| 6 |
+
buildCommand: "pip install --upgrade pip && pip install -r backend/requirements.txt"
|
| 7 |
+
startCommand: "cd backend && uvicorn main:app --host 0.0.0.0 --port $PORT"
|
| 8 |
+
envVars:
|
| 9 |
+
- key: PYTHON_VERSION
|
| 10 |
+
value: 3.11.14
|
| 11 |
+
- key: DEBUG
|
| 12 |
+
value: false
|
| 13 |
+
- key: CORS_ORIGINS
|
| 14 |
+
value: "*"
|
| 15 |
+
- key: MAX_FILE_SIZE_MB
|
| 16 |
+
value: 50
|
| 17 |
+
- key: MAX_ANALYSIS_SIZE_MB
|
| 18 |
+
value: 10
|
| 19 |
+
- key: RATE_LIMIT_PER_MINUTE
|
| 20 |
+
value: 10
|
| 21 |
+
- key: CACHE_TTL_MINUTES
|
| 22 |
+
value: 60
|
| 23 |
+
- key: MAX_CACHE_SIZE
|
| 24 |
+
value: 500
|
| 25 |
+
- key: LOG_LEVEL
|
| 26 |
+
value: INFO
|
| 27 |
+
healthCheckPath: /api/v1/health
|
| 28 |
+
disk:
|
| 29 |
+
name: verifile-cache
|
| 30 |
+
mountPath: /opt/render/project/.cache
|
| 31 |
+
sizeGB: 1
|
| 32 |
+
|
| 33 |
+
# Frontend Static Site
|
| 34 |
+
- type: static
|
| 35 |
+
name: verifile-x
|
| 36 |
+
buildCommand: "echo 'No build needed - static HTML'"
|
| 37 |
+
staticPublishPath: ./frontend
|
| 38 |
+
headers:
|
| 39 |
+
- path: /*
|
| 40 |
+
name: X-Frame-Options
|
| 41 |
+
value: DENY
|
| 42 |
+
- path: /*
|
| 43 |
+
name: X-Content-Type-Options
|
| 44 |
+
value: nosniff
|
| 45 |
+
- path: /*
|
| 46 |
+
name: Referrer-Policy
|
| 47 |
+
value: no-referrer
|
| 48 |
+
- path: /*
|
| 49 |
+
name: Cache-Control
|
| 50 |
+
value: public, max-age=3600
|