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

Handling CORS headers inside a function #41

Closed
nerdguru opened this issue Oct 9, 2018 · 4 comments
Closed

Handling CORS headers inside a function #41

nerdguru opened this issue Oct 9, 2018 · 4 comments

Comments

@nerdguru
Copy link

nerdguru commented Oct 9, 2018

Hi there,

I'm trying to use fn and Golang to build an API that is callable from a browser. Within my function, I'd like to be able to handle CORS headers on the HTTP response, but I'm finding that fdk.setHeader() is prepending text to my header name, but it doesn't do it for the Content-Type examples provided.

So if I do this in my function:

	fdk.SetHeader(out, "Access-Control-Allow-Origin", "*")
	fdk.SetHeader(out, "Content-Type", "application/json")

I see this if you hit the function with curl -v

< Content-Type: application/json
< Fn-Http-H-Access-Control-Allow-Origin: *

So, I can set Content-Type directly but not add CORS headers to the response so that the browser will handle it correctly.

Any guidance?

@denismakogon
Copy link
Member

Hi! There's a lot of work being done for Go FDK here: #39.
I recommend you to try that PR and see if that works for you.

@nerdguru
Copy link
Author

nerdguru commented Oct 9, 2018

Hi Denis, thanks for the pointer and I'm sorry for missing that. That's definitely the right conversation and it looks like you're close to solving the larger set of issues. I'll move onto Java while you're working on it in parallel. Feel free to close this one if you want and I'll track the other.

@mi-hol
Copy link

mi-hol commented Nov 26, 2018

@nerdguru with #39 closed via merged commit 26ed643 into master on Oct 25' this should unblock fonk-apps/fonk-examples#6

@rdallman
Copy link
Contributor

this may be closed then? feel free to re-open if that is not the case. when using http triggers the headers should be returned from the function and from the trigger endpoint as expected (without a prefix).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants