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

248
Views
aplicación nuxt implementada en Netlify: buscar en la API que funciona localmente, pero no en el sitio implementado: obtener un 404

Tengo una aplicación Nuxt.js que intento implementar en Netlify, y todo funciona en mi máquina local, pero la solicitud de recuperación a la API devuelve un 404 cuando se implementa en Netlify. No sé cómo hacer que esa ruta de servidor esté disponible para mi cliente cuando se implementa.

la solicitud de recuperación en mi archivo api-client.js se ve así:

 async fetchInfo(state) { let response = await fetch(`/api/info/${state}`); let data = await response.json(); return data; }

y la API se ve así (en el archivo api/index.js):

 const rp = require('request-promise'); const apiKey = process.env.POLICY_API_KEY; export default function (req, res, next) { if (req.url.includes("/info")) { let stateAbbr = req.originalUrl.slice(-2); rp({ uri: `https://third-party-api-here.com/states/${stateAbbr}/`, method: 'GET', headers: { 'token': apiKey, }, json: true }).then(function success(response) { if (response) { res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify(response)); return; } }).catch(function error(response) { console.log('error', response.error); }); return; } next(); }

¿Creo que esto podría tener algo que ver con CORS? Recibo este error en el navegador cuando intento acceder a esa ruta en la aplicación implementada: GET https://my-app-name.netlify.app/api/info/MN 404 SyntaxError: Unexpected token < in JSON at position 0

about 4 years ago · Juan Pablo Isaza
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!