0

I am beginner in nodejs. I am using axios with nodejs. In my case example website https://web.com, makes axios GET api call to (https://api.com) which redirects to authentication client(https://authclient.com) and validate the request and sets few cookies in WebBrowser, in response it gives redirection url to (https://api.com&response_state=somevalue) which serves output to the main site http://web.com

Here at the time of redirection from https://authclient.com to https://api.com is not happening on first time giving response code as 302 with throwing error as

Access to XMLHttpRequest at 'https:authclient.com&redirect_uri=http:api.com/' (redirected from 'https://api.com&response_state=somevalue') from origin 'https://web.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

After multiple refreshes the page is loading fine.

Here is the same code making call from https://web.com

axios.get("https://api.com/validate,{
headers:{"Access-Control-Allow-Origin" :"*"}
}).then(response).catch(error);

Could you please help me here to resolve CORS issue

PS: Installing CORS plug-in on Web Browser is not working

psr
  • 25
  • 7
  • Does this answer your question? [Access to fetch at https://accounts.google.com/o/oauth2/v2/auth has been blocked by CORS](https://stackoverflow.com/questions/72382892/access-to-fetch-at-https-accounts-google-com-o-oauth2-v2-auth-has-been-blocked) – Heiko Theißen Aug 21 '23 at 11:35
  • Nope. After redirecting to https://api.com(Backend endpoint) the user involvement won't be there. – psr Aug 21 '23 at 12:44

0 Answers0