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

197
Views
Firebase Cloud Function 'http://localhost:8100' has been blocked by CORS policy

I am testing a cloud function with the firebase emulator. I am having a problem with CORS policy. I tried as well to put:

const cors = require('cors')({ origin: true }); 
.....
cors(data, context, async () => {...}

This is the full cloud function:

export const createCheckoutSessionGreen = functions.https.onCall(
  (data: any, context: any) => {
    cors(data, context, async () => {
      const session = await stripe.checkout.sessions.create({
        payment_method_types: ['card'],
        mode: 'payment',
        success_url: window.location.origin,
        cancel_url: window.location.origin,
        line_items: [
          {
            price_data: {
              currency: 'eur',
              product_data: {
                name: data,
              },
              unit_amount: 1.99 * 100,
            },
            quantity: 1,
          },
        ],
      });
      return session.id;
    });
  }
);

But I always get the same error:

Access to fetch at 'http://localhost:5001/..../us-central1/createCheckoutSessionGreen' from origin 'http://localhost:8100' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

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!