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

Added sample for handling CORS requests. #721

Merged
merged 5 commits into from
Aug 30, 2018

Conversation

michaelawyu
Copy link
Contributor

No description provided.

@michaelawyu michaelawyu requested a review from ace-n August 24, 2018 22:20
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 24, 2018
@codecov
Copy link

codecov bot commented Aug 24, 2018

Codecov Report

Merging #721 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a8b5971...86417e4. Read the comment docs.

Copy link
Contributor

@ace-n ace-n left a 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
Copy link
Contributor

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. :)

// [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
Copy link
Contributor

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.corsEnabledFunctionAuth(mocks.preflightReq, mocks.res);

t.true(mocks.res.status.calledOnceWith(204));
t.true(mocks.res.send.called);
Copy link
Contributor

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?

Copy link
Contributor

@ace-n ace-n left a 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?

@michaelawyu
Copy link
Contributor Author

@ace-n Completed requested changes. PTAL.

@codecov
Copy link

codecov bot commented Aug 29, 2018

Codecov Report

Merging #721 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 77e8968...f01a1f4. Read the comment docs.

@ace-n ace-n force-pushed the michaelawyu-patch-functions-cors branch from f09d23f to f01a1f4 Compare August 30, 2018 20:43
ace-n pushed a commit that referenced this pull request Nov 17, 2022
Change-Id: I5884ac5267ca2ec3a2aeff996ca21ea9ef5932c8
ace-n pushed a commit that referenced this pull request Nov 17, 2022
Change-Id: I5884ac5267ca2ec3a2aeff996ca21ea9ef5932c8
ace-n pushed a commit that referenced this pull request Nov 17, 2022
Change-Id: I5884ac5267ca2ec3a2aeff996ca21ea9ef5932c8
ace-n pushed a commit that referenced this pull request Nov 17, 2022
Change-Id: I5884ac5267ca2ec3a2aeff996ca21ea9ef5932c8
ace-n pushed a commit that referenced this pull request Nov 17, 2022
Change-Id: I5884ac5267ca2ec3a2aeff996ca21ea9ef5932c8
Shabirmean pushed a commit that referenced this pull request Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants