-
Notifications
You must be signed in to change notification settings - Fork 44
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
feat: Add CORS capability to HTTP API #467
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with a couple of non-blocking comments (mostly on your comments/questions) :)
Re-approving via comment after the latest changes. Looks good :) |
0c7a7ef
to
945730e
Compare
After #389 merges (if that is the case), I suggest that the CORS configuration should then be part of top-level |
Yupp, was going to mention this. We should find a way to track PRs that need to make changes to the config stuff (once its merged) |
945730e
to
6862080
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you get a chance to test this with Apolo Studio? I tried (maybe I am doing something wrong) and it gives me a 404, or asks me Are CORS headers present?
.
Could you give me the details of your request please? (Method, URL, Body, Headers). Apollo is giving me some problems with local requests so I'll have to try something different to test it out. |
6862080
to
d38df73
Compare
So, I just go to https://www.apollographql.com and login and try to get it set up with defradb. Idk what |
I made it work. Because the config PR hasn't been merged, there is still no way to set the allowedOrigins from the cli. You have to set it up manually in the code. Go to s := http.NewServer(db, http.WithAddress(config.Database.Address), http.WithAllowedOrigins("https://studio.apollographql.com")) |
Awesome. Cheers! |
tweek strucs to have options field instead of embedded serverOption struct change CORS to only apply if allowedOrigins is explicitely set
d38df73
to
31a5179
Compare
Codecov Report
@@ Coverage Diff @@
## develop #467 +/- ##
===========================================
+ Coverage 52.46% 52.55% +0.09%
===========================================
Files 97 97
Lines 13144 13170 +26
===========================================
+ Hits 6896 6922 +26
Misses 5574 5574
Partials 674 674
|
RELEVANT ISSUE(S) Resolves sourcenetwork#408 DESCRIPTION This PR adds CORS capability to the HTTP API. In situations where the database will be accessed from a different domain than that of the Defra host, the HTTP API needs to communicate to the browser the allowed origins and handle preflight requests.
RELEVANT ISSUE(S)
Resolves #408
DESCRIPTION
This PR adds CORS capability to the HTTP API. In situations where the database will be accessed from a different domain than that of the Defra host, the HTTP API needs to communicate to the browser the allowed origins and handle preflight requests.
HOW HAS THIS BEEN TESTED?
Unit tests and
curl
withallowedOrigins
set tohttp://test.com
CHECKLIST:
ENVIRONMENT / OS THIS WAS TESTED ON?
Please specify which of the following was this tested on (remove or add your own):