Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API redirects & CORS #389

Merged
merged 10 commits into from
Apr 6, 2020
Merged

API redirects & CORS #389

merged 10 commits into from
Apr 6, 2020

Conversation

kevee
Copy link
Member

@kevee kevee commented Apr 3, 2020

Added API redirects to the new "V1" prefixed API.
Added CORS header

Fixes #386
Fixes #384

@kevee
Copy link
Member Author

kevee commented Apr 3, 2020

I tested a few original URLs off this deploy preview and I think we're looking good. @webmasterkai - wanna check?

https://deploy-preview-389--upbeat-lovelace-3e9fff.netlify.com/

@kevee kevee requested a review from webmasterkai April 3, 2020 12:30
@kevee
Copy link
Member Author

kevee commented Apr 4, 2020

So we still want /api/states to get proxied to the API endpoint?

@webmasterkai
Copy link
Contributor

If we set a redirect as /api/states it doesn't handle query args that aren't anticipated like ?grade=B. Checking the logs a bunch of endpoints have various args that Cloudflare still needs to resolve.

@kevee
Copy link
Member Author

kevee commented Apr 4, 2020

Got it, thanks!

@kevee
Copy link
Member Author

kevee commented Apr 5, 2020

If there is a list of used query parameters, I'm fine with putting those in redirects in the interest in getting the bulk of traffic off to static files.

Any "new" parameters folks use, of course, won't work, but that means they read the docs and see that things have changed.


/api/states/daily state=:state date=:date     /api/v1/states/:state/:date.json
/api/states/daily state=:state                      /api/v1/states/:state/daily.json
/api/states/daily state=:state grade:grade                      https://covid.cape.io/states?state=:state&grade=:grade 200
... ad nauseum with all possible query param combos
/api/states/daily                /api/vi/states/daily.json
 

@kevee
Copy link
Member Author

kevee commented Apr 5, 2020

If nothing else, what we can do here is use Netlify functions to just take those requests, read the static JSON, filter, and respond with the data.

@webmasterkai webmasterkai merged commit 2c5f9df into COVID19Tracking:master Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: Add Redirects to netlify config API: Add some CORS headers to netlify config for json files
2 participants