0

I am building an app in vue.js and using axios for my http requests. I am trying to make a request to a 3rd party API but I keep getting Response for preflight has invalid HTTP status code 403. However, the exact same request works if I use postman. My request:

axios({
  method: "get",
  url: "www.xxx.com/api/v1/xxx",
  headers: {
    'Access-Control-Allow-Origin': '*',
    'Content-Type': 'application/json; charset=utf-8',
    authorization: authToken,
    accept: 'application/json'
  }
}).then(res => {
  // do something 
}).catch(err => {
  // handle error
})

Note - I am using google chrome and have the CORS extension activated.

Can someone help

Thanks in advance!

ichigolas
  • 7,595
  • 27
  • 50
Trung Tran
  • 13,141
  • 42
  • 113
  • 200
  • So they do not support preflight... – epascarello Sep 28 '17 at 16:11
  • Why do you have a `Access-Control-Allow-Origin` header on your request? It is a response header. It is nonsense to put it on a request. – Quentin Sep 28 '17 at 16:16
  • Why do you have a `Content-Type` header on your request? It is a GET request. There is no request body to describe the content type of. – Quentin Sep 28 '17 at 16:16
  • "I am using google chrome and have the CORS extension activated" — The CORS extension is a dirty hack that doesn't handle preflight requests properly. – Quentin Sep 28 '17 at 16:17
  • thanks for the feedback - could you advise what I should do then? @Quentin all the tutorials i've read so far tell me to add `'Access-Control-Allow-Origin': '*',`, but that gives me `No 'Access-Control-Allow-Origin' header is present on the requested resource. ` – Trung Tran Sep 28 '17 at 16:35
  • The tutorials should be telling you to add that to the **response**, not the request. – Quentin Sep 28 '17 at 16:40

0 Answers0