@@ -393,18 +393,6 @@ export default {
393393 window .URL .revokeObjectURL (url)
394394 }
395395
396- // Get API port from configuration file
397- const getApiPort = async () => {
398- try {
399- const configResponse = await fetch (' ../config.json' )
400- const config = await configResponse .json ()
401- return config .api_port || 5000
402- } catch (error) {
403- console .warn (' Could not load config.json, using default port 5000:' , error)
404- return 5000
405- }
406- }
407-
408396 // ===== MAIN FORM SUBMISSION =====
409397
410398 // Handle form submission and PDF generation
@@ -431,10 +419,16 @@ export default {
431419 loading .value = true
432420
433421 try {
434- // Build API request URL
435- const apiPort = await getApiPort ()
436- const currentDomain = window .location .origin
437- const apiUrl = ` ${ currentDomain .replace (/ :\d + $ / , ' ' )} :${ apiPort} /api/generate-report`
422+ // Build API request URL using .env variable
423+ const port = import .meta.env.VITE_API_PORT || ' 443'
424+ const origin = window .location .origin
425+
426+ // Remove port from origin (e.g., http://localhost:3000 => http://localhost)
427+ const domain = origin .replace (/ :\d + $ / , ' ' )
428+
429+ // If using default HTTPS or HTTP ports, don't add the port in the URL
430+ const showPort = ! [' 80' , ' 443' ].includes (port)
431+ const apiUrl = ` ${ domain}${ showPort ? ` :${ port} ` : ' ' } /api/generate-report`
438432
439433 // Prepare request payload for API
440434 const requestBody = {
0 commit comments