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

367
Views
Node js Heroku No hay encabezado 'Access-Control-Allow-Origin' en el recurso solicitado

Tengo la siguiente configuración de encabezados en mi aplicación node js api:

 res.header("Access-Control-Allow-Origin", "*"); res.header( "Access-Control-Allow-Headers", "Origin, X-Requested, Content-Type, Accept Authorization" ); if (req.method === "OPTIONS") { res.header( "Access-Control-Allow-Methods", "POST, PUT, PATCH, GET, DELETE" ); return res.status(200).json({}); } next(); });

Con esta configuración, puedo enviar solicitudes GET, POST a mi API alojada en Heroku desde Postman. Pero cuando intento desde mi aplicación frontend creada con vue. Obtuve el siguiente error.

ingrese la descripción de la imagen aquí

Y estoy usando fetch para enviar la solicitud a la API remota:

 async signup() { try { const formData = new FormData(); formData.firstName = this.firstName; formData.lastName = this.lastName; formData.email = this.email; formData.password = this.password; formData.confirmPassword = this.password; formData.mobile = this.mobile; formData.gender = this.gender; formData.profileImg = this.profileImg; const response = await fetch( "https://api-url.com/auth/patient/signup", { body: formData, method: "POST", } ); const data = await response.json(); this.response = JSON.stringify(data); } catch (error) { console.log(error); } }

¿Alguien puede señalar los errores que he cometido aquí?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que necesita configurar los encabezados en la llamada de búsqueda. Veo que ya ha agregado cuerpo y método.

 headers: { 'Content-Type': 'application/json' }
about 4 years ago · Juan Pablo Isaza Report
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!