I'm able to make this request without any error using python:
async def send_request():
session = aiohttp.ClientSession()
body = {
'client_id': 'play-valorant-web-prod',
'nonce': '1',
'redirect_uri': 'https://playvalorant.com/opt_in',
'response_type': 'token id_token',
}
response = await session.post('https://auth.riotgames.com/api/v1/authorization', json=body)
print(response)
But then I try doing the same thing inside my website using Javascript and Axios:
async function send_request() {
const data = {
"client_id": "play-valorant-web-prod",
"nonce": "1",
"redirect_uri": "https://playvalorant.com/opt_in",
"response_type": "token id_token"
}
const response = await axios.post('https://auth.riotgames.com/api/v1/authorization', data)
console.log(response)
}
And I get the following error:
Access to XMLHttpRequest at 'https://auth.riotgames.com/api/v1/authorization' from origin
'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't
pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Is there a way of making this request from my website?
Many thanks!