ScottishCovidResponse / rampvis-api

Node and Python FastAPI based RESTful APIs. The APIs are used by (1) RAMPVIS user interface: https://github.com/ScottishCovidResponse/rampvis-ui and (2) RAMPVIS Infrastructure management user interface: https://github.com/saifulkhan/rampvis-ontology-management-ui
BSD 2-Clause "Simplified" License
6 stars 4 forks source link

CORS Regex #23

Closed saifulkhan closed 2 years ago

saifulkhan commented 2 years ago

For example test: https://deploy-preview-119--rampvis-ui-development.netlify.app/page?id=6181746e3f35852412f6b3b4

kachkaev commented 2 years ago

Happy to submit a PR for that to unblock us

saifulkhan commented 2 years ago

It will be great :)

kachkaev commented 2 years ago

Done in #27

saifulkhan commented 2 years ago

Looks like the issue is still there.

Test cases:

  1. infrastructure-api (Javascript): Open and see if the list of dashboards are loaded https://deploy-preview-119--rampvis-ui-development.netlify.app/dashboard

  2. data-api (Python): Open and see if the data is being served https://deploy-preview-119--rampvis-ui-development.netlify.app//stat/v1/data/?product=phe&component=newPeopleVaccinatedThirdInjectionByPublishDate&format=long

The CORS check in the Python API happens in: https://github.com/ScottishCovidResponse/rampvis-api/blob/main/data-api/app/main.py#L19 We need to review this part of the code too.

kachkaev commented 2 years ago

@saifulkhan what is the value of our env var? Do we have *--rampvis-ui-development.netlify.app in the list of origins?

I did not know about the python routes, not sure what to suggest there!

saifulkhan commented 2 years ago

Yes, I shared the config (it's a private repo) folder with you. https://github.com/saifulkhan/rampvis-config/blob/main/production.json

kachkaev commented 2 years ago

Right. Looks like we’ll need to enable allow_origin_regex in python change the config to some regex 🤔

https://fastapi.tiangolo.com/tutorial/cors/

JS implementation would need to change too for parity.

kachkaev commented 2 years ago

Let me give it a try now

saifulkhan commented 2 years ago

Yes, I wonder what should be the value of allow_origin_regex, "*--rampvis-ui-development.netlify.app"?

kachkaev commented 2 years ago

28

kachkaev commented 2 years ago

🤞