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

298
Views
Sin 'Acceso-Control-Permitir-Origin' - Función Firebase

Creé una solicitud GET usando funciones de base de fuego. Puedo recibir datos usando Postman, pero no desde mi aplicación FE.

Al acceder a los puntos finales, recibo este error

 from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Mi código FE,

 pay() { this.http.get(this.settings.createPaymentRequest).subscribe(res => { console.log(res); }) }

código del servidor,

 exports.createRequest = functions.https.onRequest((req, res) => { const cors = require('cors')({ origin: '*' }); ... var options = { method: 'POST', uri: 'https://test.instamojo.com/api/1.1/payment-requests/', form: payload, headers: insta_headers, json: true }; return rp(options) .then(function (response) { console.log(response); if (response.success) { db.collection('PAYMENT_REQUESTS').doc(response.payment_request.id).set({ LONG_URL: response.payment_request.longurl, REQUEST_CREATED_AT: response.payment_request.created_at, PAYMENT_STATUS: "STARTED" }, { merge: true }).then(function () { response.setHeader(headers); res.status(200).send({ STATUS: "SUCCESS", RESPONSE: response.payment_request.longurl }); }) .catch(function (error) { res.status(200).send({ STATUS: "ERROR", RESPONSE: error }); }); } else return res.status(403).send('Forbidden!'); }) .catch(function (e) { console.log("ERROR" + e); res.status(200).send({ STATUS: "ERROR", RESPONSE: e }); }); });

Por favor guíame como resolver este problema.

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

0

Parece que tu creaste esto

 const cors = require('cors')({ origin: '*' });

pero no lo inyecte en ningún lado (a menos que sea parte del ... )

Debería haber algo como esto en alguna parte

 app.use(cors())

(o como lo haga su marco)

Antes de volver a intentar con su navegador, puede verificar los encabezados de respuesta en cartero para ver si los encabezados cors que está buscando están allí:

algo como esto:

 Access-Control-Allow-Origin: *
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!