Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

246
Views
siguiente js cómo obtener la URL del servidor en getServerSideProps para obtener datos del servidor api actual

Obviamente, este código siempre devuelve 404, debido a la ruta de búsqueda 'api/registro/' + nombre de usuario , no funciona correctamente con la ruta relacionada. No veo la solución en ninguna parte. Todos solo codifican un enlace como http://localhost:3000/api/registration/something pero ¿por qué debería codificarlo? ¿Hay alguna forma civilizada de obtener datos de la API del servidor actual, donde en realidad se llamó a getServerSideProps? (eso no funcionaría, pero de todos modos window.location.host+"/api/registration/something")

 import axios from 'axios'; import { UserData } from '../src/common/types/user-types/UserData'; export default function UsernamePage(props) { console.log('Got props', props); return <div>Username Page</div>; } export async function getServerSideProps({ params: { username }, ...rest }) { console.log(rest); try { const { data } = await axios.get<UserData>('api/registration/' + username); return { props: { ...data } }; } catch (e) { return { notFound: true }; } }
about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!