Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

154
Visualizações
No 'Access-Control-Allow-Origin' header is present on the requested resource when a header is present on the requested source

Sorry for asking this question when it's a lot of answers to these questions out there already, but I have tried almost everything and it's still not working. I'm making an API call to an API hosted on replit. This has worked fine until yesterday, I don't know what I did yesterday that f*cked up my code. When making the API call, I get the CORS error: No 'Access-Control-Allow-Origin' header is present on the requested resource, but I have a header with 'Access-Control-Allow-Origin' in my response.

Really appreciate all your help!

API code:

app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())

app.use(cors())

app.post('/invoicing', cors(), async (req, res) => {
  res.header('Access-Control-Allow-Origin', '*');
  res.header('crossorigin', 'true')
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); 
    try {
        const product = await stripe.products.create({
            name: 'Test'
        })

        const price = await stripe.prices.create({
            product: product.id,
            unit_amount: 10000,
            currency: 'nok',
        })

    const customer = await stripe.customers.create({
            name: 'Daniel Olsen',
            email: 'olsen.daniel04@gmail.com',
            description: 'Customer',
        })

        const invoiceItem = await stripe.invoiceItems.create({
            customer: customer.id,
            price: price.id,
        })

        const invoice = await stripe.invoices.create({
            customer: customer.id,
            auto_advance: true,
        })

        const invoiceFinalize = await stripe.invoices.finalizeInvoice(invoice.id)

        console.log(invoiceFinalize)
        console.log(customer)
        res.json({
            success: true,
            message: 'Yeeet'
        })

    } catch (error) {
        console.log(error)
        res.json({
            message: "Payment failed",
            success: false
        })
    }
})
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda