fix
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import './App.css'
|
||||
|
||||
// Configure API base URL via Vite env, default to same-origin
|
||||
const API_BASE = import.meta.env.VITE_API_BASE || ''
|
||||
|
||||
function App() {
|
||||
const [nombre, setNombre] = useState('')
|
||||
const [amigos, setAmigos] = useState([])
|
||||
@@ -13,7 +16,7 @@ function App() {
|
||||
|
||||
const fetchAmigos = async () => {
|
||||
try {
|
||||
const response = await fetch('http://localhost:3001/api/amigos')
|
||||
const response = await fetch(`${API_BASE}/api/amigos`)
|
||||
const data = await response.json()
|
||||
setAmigos(data)
|
||||
} catch (error) {
|
||||
@@ -33,7 +36,7 @@ function App() {
|
||||
setMessage('')
|
||||
|
||||
try {
|
||||
const response = await fetch('http://localhost:3001/api/amigos', {
|
||||
const response = await fetch(`${API_BASE}/api/amigos`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
Reference in New Issue
Block a user