svrcekmichal / redux-axios-middleware

Redux middleware for fetching data with axios HTTP client
MIT License
920 stars 96 forks source link

How i can do cross domain request? #73

Closed DisaPadla closed 6 years ago

DisaPadla commented 6 years ago

I set "Access-Control-Allow-Origin: *", but always get a warning: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

nmaves commented 6 years ago

The preflight/CORS is handled by the browser, not by axios or this middleware.

You need to make sure your server allows for CORS requests.

DisaPadla commented 6 years ago

@nmaves but if i use just axios, like:

axios.post('https://another_url', data, {
      'Access-Control-Allow-Origin': '*',
      Accept: 'application/json',
    })

all works fine

nmaves commented 6 years ago

Those are not valid configuration options per https://github.com/axios/axios#request-config. Honestly, those are headers that the server should set. I would remove them altogether.