Add CORS header to an http request using Ajax

You can’t authorize yourself like that. It’s a response header; details in the specification. The server you’re sending the request to has to send that header back to let the browser know it’s okay to allow your page to send an ajax request to that server. There’s nothing you can do in your client-side code if the server you’re trying to request from doesn’t allow your origin.

Leave a Comment