sjdkadbksjdkadbk
This commit is contained in:
		
							parent
							
								
									e7c0f9f334
								
							
						
					
					
						commit
						4974e7d6f3
					
				
					 1 changed files with 15 additions and 1 deletions
				
			
		|  | @ -7,7 +7,21 @@ const defaultApiBase = | |||
|     ? 'https://backend.basetracker.lona-development.org' | ||||
|     : 'http://localhost:4100'; | ||||
| 
 | ||||
| const API_BASE = process.env.NEXT_PUBLIC_BACKEND_URL ?? defaultApiBase; | ||||
| // Normalize backend URL so production always uses HTTPS while keeping local HTTP.
 | ||||
| function normalizeApiBase(url: string) { | ||||
|   try { | ||||
|     const parsed = new URL(url); | ||||
|     const isLocalhost = ['localhost', '127.0.0.1', '0.0.0.0'].includes(parsed.hostname); | ||||
|     if (!isLocalhost && parsed.protocol === 'http:') { | ||||
|       parsed.protocol = 'https:'; | ||||
|     } | ||||
|     return parsed.toString().replace(/\/$/, ''); | ||||
|   } catch (_error) { | ||||
|     return url.replace(/\/$/, ''); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| const API_BASE = normalizeApiBase(process.env.NEXT_PUBLIC_BACKEND_URL ?? defaultApiBase); | ||||
| 
 | ||||
| const API = { | ||||
|   signup: `${API_BASE}/auth/signup`, | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Hymmel
						Hymmel