-
Notifications
You must be signed in to change notification settings - Fork 201
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
Request for overriding DefaultServerAddress #13
Comments
@jeroenkoknl Could you help me understand what issue this is causing in your scenario? Do you have a code example you could share? As I see it, the handlers that use the generated I've used this same method in mocking out test cases with no real impact on the HandlerFunc; as long as the response produces what we want, we should be ok. |
Hi @dave-malone, thank you for looking into this issue. The issue is that the We tried to work around this by ignoring the I'll have a look at your test cases to see if I can point out a way to easiliy test this scenario for you. |
Hi @jeroenkoknl, @dave-malone - we have been struggling with this on our java framework too. Unfortunately, the only way to tell the original host the client contacted is to trust the We have asked the API Gateway team to add the full client request url to the proxy object. until then, I would recommend using environment variables in Lambda to statically set the url the API is running on, you can populate them using a reference in the SAM template (look at the exported values in the sample) |
For what it's worth, this also makes the traces in X-Ray ( |
@captainbeardo that issue we could address with a similar methodology of the Java framework. I was just hoping to go for something cleaner and get the domain directly from API GW. Perhaps using an environment variable is an acceptable solution for the time being. What do you think @jeroenkoknl? |
@sapessi Yes, using an environment variable could work, although it doesn't help in a scenario where the same Lambda handler service multiple domains. In that case the original host address should come from the request. We are relying on AWS API Gateway to forward this information. I was under the impression this was already done but your comment on May 15 suggest this isn't the case. Maybe for the time being provide a way to override the DefaultServerAddress by for instance an environment variable? |
Hi @jeroenkoknl, I've checked the proxy event again and it does not contain the original request uri. I will implement the environment variable fix by the end of this week. |
Thanks @sapessi for doing this! |
Any progress on this? Thanks :D |
…a request in the environment variable
Fix for this is now in PR #21 - let me know if the proposed changes work for you. |
Resolving since PR is merged |
The proxied
http.Request
URL will currently always start withhttps://aws-serverless-go-api.com
because of the way the the URL is created here: https://github.com/awslabs/aws-lambda-go-api-proxy/blob/master/core/request.go#L137This is an issue when API Gateway is configured to use a custom domain. For instance Gorrila MUX will redirect the client to a 'clean' version of the URL path. It makes use of the request URL to construct the redirect URL in de HTTP response: https://github.com/gorilla/mux/blob/master/mux.go#L125-L137
Could you please create the ability to override the server address? Another option would be to use the value of
request.host
in the API Gateway Proxy Request Event.The text was updated successfully, but these errors were encountered: