-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Added sample for handling CORS requests. #721
Conversation
Codecov Report
@@ Coverage Diff @@
## master #721 +/- ##
=======================================
Coverage 55.17% 55.17%
=======================================
Files 1 1
Lines 58 58
=======================================
Hits 32 32
Misses 26 26 Continue to review full report at Codecov.
|
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.
LGTM once the if-statement comment is resolved. 👍
.gitignore
Outdated
@@ -10,3 +10,4 @@ logs/ | |||
.nyc_output | |||
yarn.lock | |||
package-lock.json | |||
.DS_Store |
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.
#nit: Ditto to what I said on the other PR - global .gitignore
. :)
functions/cors/index.js
Outdated
// [START functions_cors] | ||
exports.corsEnabledFunction = (req, res) => { | ||
// Set CORS headers for preflight requests | ||
// e.g. allow GETs from any origin with the Content-Type header |
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.
Can/should we put these headers in one big if
block, instead of removing them when they don't apply?
cc @stew-r
functions/cors/test/index.test.js
Outdated
functions.corsEnabledFunctionAuth(mocks.preflightReq, mocks.res); | ||
|
||
t.true(mocks.res.status.calledOnceWith(204)); | ||
t.true(mocks.res.send.called); |
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.
Nit: check that it was called a certain number of times?
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.
Edit: would you mind moving these into the HTTP
folder and using functions_http_*
region tags?
@ace-n Completed requested changes. PTAL. |
Codecov Report
@@ Coverage Diff @@
## master #721 +/- ##
=======================================
Coverage 55.17% 55.17%
=======================================
Files 1 1
Lines 58 58
=======================================
Hits 32 32
Misses 26 26 Continue to review full report at Codecov.
|
f09d23f
to
f01a1f4
Compare
Change-Id: I5884ac5267ca2ec3a2aeff996ca21ea9ef5932c8
Change-Id: I5884ac5267ca2ec3a2aeff996ca21ea9ef5932c8
Change-Id: I5884ac5267ca2ec3a2aeff996ca21ea9ef5932c8
Change-Id: I5884ac5267ca2ec3a2aeff996ca21ea9ef5932c8
Change-Id: I5884ac5267ca2ec3a2aeff996ca21ea9ef5932c8
No description provided.