Reputation: 11064
I have alot of CDN links that I want to add a CORS header to. I am looking to do the equivalent of:
curl -X POST -H "X-Auth-Token: dddddsssb04411b4c6a2" -H "Access-Control-Allow-Origin: *" https://verylong/url
using the request module.
I have tried:
payload = { Access-Control-Allow-Origin: '*' }
headers = {'content-type': 'application/json'}
r = requests.post(link, data=json.dumps(payload), headers=headers)
and I have tried:
s = requests.Session()
s.get(link)
s.headers.update({ Access-Control-Allow-Origin: '*' })
To no success. How can I do the equivalent of the curl statement with the request module?
Upvotes: 0
Views: 417
Reputation: 510
I think the access-control-allow-origin is not payload. Try put it into header.
headers = {
"X-Auth-Token": "dddddsssb04411b4c6a2",
"Access-Control-Allow-Origin": "*",
}
r = requests.post("https://verylong/url", headers=headers)
Upvotes: 1