Make backend API URL configurable via environment variables
Updated frontend to use BACKEND_API_URL environment variable at compile time with fallback to localhost. Added configuration to Trunk.toml and .env.example for development. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
10
src/auth.rs
10
src/auth.rs
@@ -50,10 +50,12 @@ pub struct AuthService {
|
||||
|
||||
impl AuthService {
|
||||
pub fn new() -> Self {
|
||||
// Default to localhost backend - could be configurable via env var in the future
|
||||
Self {
|
||||
base_url: "http://localhost:3000/api".to_string(),
|
||||
}
|
||||
// Get backend URL from environment variable at compile time, fallback to localhost
|
||||
let base_url = option_env!("BACKEND_API_URL")
|
||||
.unwrap_or("http://localhost:3000/api")
|
||||
.to_string();
|
||||
|
||||
Self { base_url }
|
||||
}
|
||||
|
||||
pub async fn register(&self, request: RegisterRequest) -> Result<AuthResponse, String> {
|
||||
|
||||
Reference in New Issue
Block a user