'OpenAI API Refused to set unsafe header "User-Agent"

I don't understand why I am receiving this error.

Refused to set unsafe header "User-Agent"

I am trying to use OpenAI's API for a personal project. I don't understand why it's refusing to set this "unsafe header" and how, or if, I can make it safe. I've tried googling this issue and the top link is for a GitHub forum that explains how it might be something that Chrome does but, I tried to use the app in Safari and it wouldn't work either.

const onFormSubmit = (e) => {
e.preventDefault();

const formData = new FormData(e.target),
  formDataObj = Object.fromEntries(formData.entries())
console.log(formDataObj.foodDescription);

//////OPENAI
const configuration = new Configuration({
  apiKey: process.env.REACT_APP_OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);

openai.createCompletion("text-curie-001", {
  prompt: `generate food suggestions from the following flavor cravings: ${formDataObj.foodDescription}`,
  temperature: 0.8,
  max_tokens: 256,
  top_p: 1,
  frequency_penalty: 0,
  presence_penalty: 0,
})
.then((response) => {
  setState({
    heading: `AI Food Suggestions for: ${formDataObj.foodDescription}`,
    response: `${response.data.choices[0].text}`
  });
})

}



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source