cityofaustin / atd-dockless-dataviz

🛴 A map for exploring dockless mobility data.
http://dockless.austintexas.io/
Other
21 stars 5 forks source link

CORS request not working to production server. #32

Closed mateoclarke closed 6 years ago

mateoclarke commented 6 years ago

I'm seeing this error when in I try to pull data from a staged client app on Netlify.

Access to fetch at 'https://dockless-data.austintexas.io/v1/trips?xy=-97.74394821167274,30.271997902824353&flow=origin&mode=all' from origin 'https://deploy-preview-31--dockless.netlify.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

After some Google-fu, here and here, it seems that we need to make the request to the backend with a header, and/or pass options into the request.

Maybe the error is misleading and the server needs to be configured to accept CORS requests, but I thought we had already done that.

Possible solution: replace d3-fetch with another ajax library

mateoclarke commented 6 years ago

Tried passing a mode option to the d3 json fetch method, but it didn't seem to help: https://github.com/cityofaustin/dockless/pull/31/commits/48209d0dea2c7c758d438a45a0acdbf6789e3d7a

mateoclarke commented 6 years ago

Going to wait on a redeploy of the most up-to-date dockless-api Python code on the server-side before changing anything about the front-end app.

mateoclarke commented 6 years ago

This is now resolved with the latest push of backend code.