Nitish Kumar
Nitish Kumar

Reputation: 6276

How to config headers in axios on Laravel application

I'm trying to build a small application on Vuejs 2.0 where I'm having axios call and in configuration I'm setting the headers something like this:

const headers = {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'origin': 'http://www.conxn.co.in',
    'Access-Control-Allow-Origin': '*'
}

And calling the url something like this:

axios.post('http://www.conxn.co.in/CoxnsvcA.svc/Login', postData,{headers: getLoginHeader()})

But I can see the origin is not changed from local host:

screenshot

Guide me how can I set the Origin to the url as mentioned.

Thanks

Upvotes: 0

Views: 2004

Answers (1)

jostrander
jostrander

Reputation: 754

That's not how CORS works. You cannot modify the origin header being sent out because that's set by the browser for security purposes. The server needs to allow the request by returning the Access-Control-Allow-Origin header. It doesn't look like the server you're requesting ajax from is setup correctly for CORS requests.

Upvotes: 1

Related Questions