Skip to content

Cross-Origin Request Blocked #203

@lukarmar

Description

@lukarmar

Em minha requisição pelo reactjs está vindo o seguinte erro:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://viacep.com.br/ws/01310940/json/. (Reason: header ‘user-agent’ is not allowed according to header ‘Access-Control-Allow-Headers’ from CORS preflight response)

Alguma solução?

Função utilizada:

import cep_promoise from 'cep-promise';
import {states} from './Cities_States';

export async function getAddressProfile (zipcode) {

  try {
    const response = await cep_promoise(zipcode);

    return {
     ...response,
      state: states.find(data => data.sigla === response.state).nome
    };

  } catch (err) {
      return err;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions