fix: use NEXT_PUBLIC_API_URL env var for API requests

This commit is contained in:
Tiago Yamamoto 2025-12-23 23:50:56 -03:00
parent 6bb90bdd1c
commit b7987dead9
2 changed files with 9 additions and 17 deletions

View file

@ -1,29 +1,20 @@
# ============================================================================= # =============================================================================
# GoHorse Jobs Frontend - Environment Variables Example # GoHorse Jobs Frontend - Environment Variables
# ============================================================================= # =============================================================================
# Copy this file to .env.local and update the values # Copy this file to .env.local and update the values
# API Backend URL # API Backend URL (just the domain, endpoints already include /api/v1)
# IMPORTANT: Include /api/v1 suffix # Examples:
# Local development: # Local development: http://localhost:8521
NEXT_PUBLIC_API_URL=http://localhost:8521/api/v1 # Production: https://api.gohorsejobs.com
# Production: NEXT_PUBLIC_API_URL=http://localhost:8521
# NEXT_PUBLIC_API_URL=https://api-dev.gohorsejobs.com/api/v1
# Seeder API URL (for admin operations) # Seeder API URL (for admin operations)
NEXT_PUBLIC_SEEDER_API_URL=http://localhost:3001 NEXT_PUBLIC_SEEDER_API_URL=http://localhost:3001
# Production:
# NEXT_PUBLIC_SEEDER_API_URL=https://seeder-dev.gohorsejobs.com
# Scraper API URL (for importing scraped jobs) # Scraper API URL (for importing scraped jobs)
NEXT_PUBLIC_SCRAPER_API_URL=http://localhost:3002 NEXT_PUBLIC_SCRAPER_API_URL=http://localhost:3002
# Production:
# NEXT_PUBLIC_SCRAPER_API_URL=https://scraper-dev.gohorsejobs.com
# Vercel Analytics (optional) # Vercel Analytics (optional)
NEXT_PUBLIC_VERCEL_ANALYTICS=false NEXT_PUBLIC_VERCEL_ANALYTICS=false

View file

@ -1,8 +1,9 @@
import { toast } from "sonner"; import { toast } from "sonner";
import { Job } from "./types"; import { Job } from "./types";
// const API_BASE_URL = "http://localhost:8521"; // Backend URL // Use this for dev // API Base URL - endpoints already include /api/v1 prefix
const API_BASE_URL = ""; // Use this for production/setup with proxy // NEXT_PUBLIC_API_URL should be just the domain, e.g. https://api.gohorsejobs.com
const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || "";
/** /**
* Helper to log CRUD actions for the 'Activity Log' or console * Helper to log CRUD actions for the 'Activity Log' or console