question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

react-axios fails Preflight CORS, while axios in react passes

See original GitHub issue

Screenshot from 2022-06-04 01-42-12 react-axios fails CORS despite access-control-allow-origin: * on the server, while running axios in react passes.

You can check it out here: Edit flamboyant-dream-d51k36

Here are the http headers:

curl -v https://jsonplaceholder.typicode.com/users
> GET /users HTTP/2                                                   
> Host: jsonplaceholder.typicode.com                                                                                                         
> user-agent: curl/7.68.0                                             
> accept: */*                                                         
< content-type: application/json; charset=utf-8                                                                                              
< x-powered-by: Express                                               
< x-ratelimit-limit: 1000                                             
< x-ratelimit-remaining: 998                                          
< x-ratelimit-reset: 1645868764                                       
< vary: Origin, Accept-Encoding                                       
< access-control-allow-credentials: true                                                                                                     
< cache-control: max-age=43200                                        
< pragma: no-cache                                                    
< expires: -1                      
< x-content-type-options: nosniff
curl -v https://bible-api.com/john%203:16
> GET /john%203:16 HTTP/2
> Host: bible-api.com
> user-agent: curl/7.68.0
> accept: */*
< HTTP/2 200 
< server: nginx
< date: Fri, 03 Jun 2022 16:07:43 GMT
< content-type: application/json;charset=utf-8
< content-length: 493
< access-control-allow-origin: *
< access-control-allow-methods: OPTIONS
< x-content-type-options: nosniff

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
sheaiveycommented, Jun 4, 2022

Ok, release v2.0.6 is out now and ready for use.

https://github.com/sheaivey/react-axios/releases/tag/v2.0.6

1reaction
sheaiveycommented, Jun 4, 2022

Oh! I thought that fix was in the latest release from a year ago. I’ll get it pushed out today. Thanks for clarifying.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Axios having CORS issue - Stack Overflow
This is happening because of restrict-origin-when-cross-origin policy.Browser sends a pre-flight request to know whom the API server wants to ...
Read more >
Request to api from axios (cross domain) (CORS) error
I'm try to fetch data from bank api with AXIOS and heve an error. ... Response to preflight request doesn't pass access control...
Read more >
Getting 'Cross-Origin Request Blocked' on a GET request #853
I have updated my code to route the request through a proxy: axios.get('https://a.4cdn.org/a/threads.json', { headers: { 'Access-Control ...
Read more >
axios has been blocked by cors policy - You.com
axios has been blocked by cors policy: response to preflight request doesn't pass access control check: no 'access-control-allow-origin' header is present ...
Read more >
Cross-origin Errors - React
Cross-origin Errors. Note: The following section applies only to the development mode of React. Error handling in production mode is done with regular ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found