-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
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.
Mind moving these into the HTTP
folder and using functions_http_*
region tags?
@ace-n Completed requested changes. PTAL. |
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 - @andrewsg PTAL? (unless you trust my outdated Python-fu 😝 )
|
||
return ('', 204, headers) | ||
|
||
# Set CORS headers for the main request |
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.
"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.
functions/http/main.py
Outdated
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 |
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.
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?
functions/http/main.py
Outdated
def cors_enabled_function_auth(request): | ||
# Set CORS headers for preflight requests | ||
# e.g. allows GETS from origin https://mydomain.com with Authorization | ||
# 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.
Likewise I'm not sure I'm clear on this comment meaning yet.
Hi @andrewsg , Basically under certain circumstances browsers need to send one empty |
Okay. Here are some suggestions:
|
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.
(Marking as Changes requested until @andrewsg's changes are addressed.)
@andrewsg I'll LGTM this once you do. |
No description provided.