Error Setting Up CORS with CDK: No ‘Access-Control...
# support
m
Error:
Copy code
Access to fetch at ‘https://api.demo.*.com/fhir/R4/Questionnaire/64878bfc-3412-48e3-bb47-4760a907cbcf’ from origin ’https://provider.demo.*.com’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: 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.
Context: I have a self-hosted instance of the Medplum server deployed using CDK. I’m facing CORS errors because the client attempting to make requests to the server is on a different domain. Problem: I followed the instructions from the documentation (https://www.medplum.com/docs/self-hosting/config-settings#server-config), including the following steps (not in this particular order): - Manually added the “allowedOrigins” parameter in AWS System Manager associated with my environment. - Updated the server config with the “allowedOrigins” as per the instructions here (https://www.medplum.com/docs/self-hosting/install-on-aws#update-the-server-config). - Tried upgrading the AWS infrastructure as suggested here (https://www.medplum.com/docs/self-hosting/install-on-aws#upgrade-aws-infrastructure). - Tried updating the server using the command
npx medplum aws update-server [env name]
. - Performed a new deployment. - Manually restarted the server in AWS. Question: Any ideas on what I might have done wrong or what else I can try to fix this issue?
a
I don't have an answer to this, but just wanted to chime in and say that I followed a similar path as you @matheus.myriad_27341 and got a similar message: Access to fetch at 'https://api.**.app/auth/method' from origin 'https://localhost:5173' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: 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.Understand this errorAI chunk-2SAFMWED.js?v=47236a36:3960 -- I added https://localhost:5173 to allowedOrigins, restartedthe production server -- but am getting the same error. Just curious if you ever figured this out?
r
@matheus.myriad_27341 (and @albert_wong ) I am trying to track this down. Can you both confirm which version of Medplum you are self hosting? You can find out by going to https://api./healthcheck
a
hi @reshma -- thanks so much for your help! Here's the version of Medplum I'm self-hosting with: { "ok": true, "version": "3.2.32-26a8c8c7b", "platform": "linux", "runtime": "v20.18.3", "postgres": true, "redis": true }
In case it is helpful, I've deployed a the standard medplum "Hello World" website here: https://hello.progressnotes.app/ -- and it is giving the same CORS errors -- so it does not seem to be related to localhost.
And for anyone following the thread there is this tidbit from @alexkg where he writes "we've gotten around this by disabling CORs in the web-browser and then removing 'Access-Control-Allow-Origin' from the header." I guess I will try that next. https://discord.com/channels/905144809105260605/1244788712269938869/1245066688274108630
Hmmm... didn't seem to work. (Or at least I couldn't figure out how to make it work...)
r
@matheus.myriad_27341 - let me know if a debugging session would be useful. https://cal.com/medplum/15
a
It works!!!! If you are from the future and reading this and trying to troubleshoot: here's some different things to try..... (BTW, hello there, future person! 🙂 ) #1 Add allowedOrigins: The first thing to try is to modify the allowedOrigins to include your domain name (under Parameter Store) and then to restart the server. You can try npx medplum aws update-server [env name] or if that doesn't seem to change anything, you can go to ECS (Elastic Containier Service), find your Cluster, and then click Update and see if that makes a difference. #2 Easiest follow-along for Medplum AWS CDK insttallation is non-root IAM User: So.... when you do the Medplum AWS CDK install and try to follow along with Rahul's excellent video --

https://www.youtube.com/watch?v=_YCYbgb63Y0▾

you should be advised that -- if you want to really follow along step by step with Rahul's video, you may wish to use an IAM User (rather than IAM Identity Center SSO). When I first followed along, I was using IAM Identity Center SSO, but it just created a layer of complexification that made it hardre to follow Rahul's tutorial. Rahul seems to use a non-root IAM User. So, if you want to follow along probably closest direct follow-along would be to use a non-root IAM User. #3: Give Assume Role Permissions: Perhaps this is the most important There is a footnote / troubleshooting Tip on the AWS medplum CDK installation page at the botom which is very important. It talks about making sure your AWS account has permission to assume the role via sts:AssumeRole, if a certain error message arises. That message is kind of hard to find in all of cascade of outputs (it showed up for me during bootstrap phase) but I saw that error / warning message and I made that adjustment -- and I don't know if it is what flipped the switch, but I think it might have and it now works! Good luck everyone, we're getting there! Step by step. And thanks so much to the amazing Medplum team!
341 Views