sheaivey / react-axios

Axios Components for React with child function callback
MIT License
180 stars 20 forks source link

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

Closed dryprogrammer closed 2 years ago

dryprogrammer commented 2 years ago

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
dryprogrammer commented 2 years ago

Found the culprit after many many days... why... :sob: https://github.com/sheaivey/react-axios/compare/v2.0.5...master

sheaivey Do you think you can push a quick fix?

Screenshot from 2022-06-04 13-21-17

sheaivey commented 2 years ago

Can you create a pull request of what you think the quick fix is? I’ll try and review the pr tomorrow and get some other version bumps in while I’m at it.

dryprogrammer commented 2 years ago

Well, the master branch already has the fix. It's just the v2.0.5 91dd6a5f2512e5e92058b8eaec1dbe7fefa815a7 is 1 commit behind.

Here was the fix: https://github.com/sheaivey/react-axios/commit/195a04245bc030815ffbe1a9ca20451d2769f7c3

sheaivey commented 2 years ago

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

sheaivey commented 2 years ago

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

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