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 samples for handling CORS requests. #1652

Merged
merged 6 commits into from
Oct 8, 2018

Conversation

michaelawyu
Copy link
Contributor

No description provided.

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

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

Mind moving these into the HTTP folder and using functions_http_* region tags?

@michaelawyu
Copy link
Contributor Author

@ace-n Completed requested changes. PTAL.

Copy link

@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 - @andrewsg PTAL? (unless you trust my outdated Python-fu 😝 )

@ace-n ace-n requested a review from andrewsg August 31, 2018 00:11

return ('', 204, headers)

# Set CORS headers for the main request
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The main request" is ambiguous here. Maybe we should just say "Set CORS headers" or perhaps "Set CORS headers for non-OPTIONS requests" if that is necessary? Also: same comment on similar line in next function.

def cors_enabled_function(request):
# Set CORS headers for the preflight request
# e.g. allows GETs from any origin with the Content-Type header
# and cache preflight response for an 3600s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this comment block. Can you try and explain it to me in more detail, and then we can use that explanation to clarify it?

def cors_enabled_function_auth(request):
# Set CORS headers for preflight requests
# e.g. allows GETS from origin https://mydomain.com with Authorization
# header
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise I'm not sure I'm clear on this comment meaning yet.

@michaelawyu
Copy link
Contributor Author

michaelawyu commented Sep 11, 2018

Hi @andrewsg ,

Basically under certain circumstances browsers need to send one empty OPTIONS request first (preflight request) before accessing a resource cross-region ("main" request). They require different sets of headers so I put these comments in the sample to separate them in a more clear way. Should I change the comment to something else?

@andrewsg
Copy link
Member

Okay. Here are some suggestions:

Copy link

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

(Marking as Changes requested until @andrewsg's changes are addressed.)

@michaelawyu
Copy link
Contributor Author

@ace-n @andrewsg Updated as requested; PTAL :)

@ace-n
Copy link

ace-n commented Oct 5, 2018

@andrewsg I'll LGTM this once you do.

@ace-n ace-n removed the needs review label Oct 8, 2018
@michaelawyu michaelawyu merged commit 779a525 into master Oct 8, 2018
@michaelawyu michaelawyu deleted the michaelawyu-patch-functions-cors branch October 11, 2018 23:27
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.

4 participants