Search code examples
vue.jsaxiosuser-agent

API requires a user-agent to be set but its a unsafe header in chrome


I've been trying to request information from the Shoppy API, and the response I'm getting on chrome and opera is this

this

In the Shoppy API documentation it says that it's required to set a user-agent which is impossible to my understanding from looking at stack overflow posts. However, the question I am wondering about is if there is a workaround?

sidenote: with firefox i successfully get a response from the API with a CORS extension enabled.

shoppy api documentation

mounted () {
 axios
  .get('https://shoppy.gg/api/v1/products/', {
    headers: {
      'Authorization': 'placeholder',
      'Access-Control-Allow-Origin': 'https://shoppy.gg',
      useCredentails: true, 'user-agent': 'Shoppy'}})
  .then(res => console.log(res))
  .catch(err => console.log(err));
  // .then(response => (this.info = response))

}

Solution

  • You only have to worry about setting a user-agent if you're using their API from a non-browser client app. If you're using their API on a Web site via a browser, then the browser's user-agent will automatically be used, without you having to do anything.