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

177
Visualizações
No 'Access-Control-Allow-Origin' header when fetch data with REACT from API

I have a test to get products from a company API.

They told me:

CORS allowed origins for local development is "http://localhost:1229"

So I set up proxy in package.json like this:

"proxy": "http://localhost:1229",

And my request is :

const apiLink = 'https://example.com/api/checkout/products/';

    fetch(apiLink, {
        method: 'POST'
    }).then(returnedData => {
        console.log(returnedData)
    }).catch(error => {
        console.log(error)
    });

But I still get this error

Access to fetch at 'https://...' from origin 'http://localhost:3000' has been blocked by CORS policy: 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
1 Respostas
Responde à pergunta

0

CORS allow get content from origin http://localhost:1229 so, try run development server on http://localhost:1229

using command on linux
PORT=1229 react-scripts start
on windows
set PORT=1229 && react-scripts start

or change package.json
"start": "PORT=1229 react-scripts start"
"start": "set PORT=1229 && react-scripts start"

about 4 years ago · Juan Pablo Isaza Relatório
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