Firebase Cloud Functions CORS Error for Stripe API

this route gives me the following CORS error
has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
The error is related to the async and await code but dont know how to resolve with firebase.

import * as functions from 'firebase-functions';  const express = require('express'); const cors = require('cors'); const stripe = require("stripe")("sk_test_0KLpj4ajduVN3s3iDqtji3fs"); const app = express();  app.use(cors({ origin: true })); app.use(express.json());  const calculateOrderAmount = (items: any) => {     return items / 100; };  app.post("/create-payment-intent", async (req: any, res: any) => {     const { items } = req.body;     const paymentIntent = await stripe.paymentIntents.create({         amount: calculateOrderAmount(items),         currency: "usd"     });     res.send({         clientSecret: paymentIntent     }); });  exports.payments = functions.https.onRequest(app); 
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.