I created an API Gateway Proxy Integration so I can access a HTTP API on an HTTPS site. This HTTP API return a .xml file that is being returned by the API Gateway. But this file is getting corrupted by the Gateway, don't know exactly why. I saw some similar situations and find out that I should add this on my HTTP Header (Integration Request):
Name Mapped from
Accept method.request.header.Accept
With that, when I send Accept:"application/vnd.ms-excel on my request, the file is returned OK.
Although, my problem is that I can't change the request. Is there a way that I can add this header on API Gateway without using lambda integration?
Thanks in advance.
Related
I'm looking after solution where AWS Api Gateway changes method endpoint Url dynamically.
I am familiar with stage variables and in Integration request I can change endpoint per method like (https://${stageVariables.Url}/api/DoSomething).
What I need is that information how parse endpoint is included in requests.
https://${RequestData.Url}/api/DoSomething
I have same Api in different locations and to implement centralized Api keys and logging services I try to forward all traffic through this one Api Gateway.
After first request client gets its endpoint information, but I don't know how to solve that clients next requests to Gateway should forward to that endpoint which client get earlier.
I got an answer from AWS support. They told that I have to make a lambda function to process all requests or just use Stage variables.
I'm not able to find any documentation about intercepting all HTTP requests passing through AWS API Gateway.
I'm trying to propose a Logging service for the backend APIs deployed on AWS API Gateway. The idea is all the HTTP requests will go through the API Gateway. If I'm able to intercept the request going through API Gateway, I can hook the logging service code.
The reason for this approach is, the logging code will be independent of the actual service code and service code won't have to be updated to include logging of request / response.
Any solutions for this?
You can put CloudFront in front of your API Gateway and then use Lambda#Edge Viewer Request to intercept all requests; we do this for logging for certain functions and it works flawlessly.
This is a good tutorial on how to setup API Gateway with CloudFront
https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-cloudfront-distribution/
It seems Claudia-bot-builder's intercept method will help you to intercept the API gateway requests. You can trigger an event for requests hitting to the API gateway.
`api.intercept(function (event) { ... });`
I have created an API using AWS api gateway which contains a mock endpoint /test.
In my response, I get the headers x-amzn-RequestId and x-amz-apigw-id. In case of an error, e.g. using a non existing endpoint /test2, I also get the x-amazn-ErrorType header.
I don't want these aws headers to be in my api response. How can these be removed?
Add CloudFront in front of your API Gateway. Then add a Lambda#Edge function for either origin response or viewer response to remove these attributes from the array.
We have an Angular SPA front end, which communicates through an AWS API Gateway to a .Net Web API hosted in a Lambda function. This configuration mandates that our API Gateway uses proxy intgeration with the Lambda.
Generally, this works well. We have enabled CORS in our API, and normal requests and responses flow as expected.
However, when something happens that breaks the API Gateway or .Net Lambda Wrapper, such as exceeding the Gateway's (non-configurable) 30-second timeout, or exceeding Lambda's max response size, the response message from the API Gateway does not contain a CORS header. As a result, regardless of the actual error, our front end registers a CORS error.
Is there some way to configure the API Gateway to always return a default CORS header?
Please note that this is happening outside of our code - there is nothing I can do inside of the C# lambda function, as this relates to errors happening above that level.
Yes, you can set it at AWS API Gateway Level
Login to AWS Console, Open API Gateway Service, Select your desired gateway.
On the left-hand side panel, select "Gateway Responses" (this will appear under your selected gateway)
now on the right-hand side, select "Default 5XX"
Add Default Headers for Cors like Access-Control-Allow-Headers, Access-Control-Allow-Methods, Access-Control-Allow-Origin
Save the changes and re-deploy the gateway.
Please refer this image to navigate to the desired section
Hope it helps.
I am trying to use AWS API Gateway to proxy requests to some REST endpoints I have running in docker containers. I set up my API Gateway method for integration type HTTP and checked 'Use HTTP Proxy integration', But this is not simply proxying my requests, it strippes out the path parameters, query string parameters and body, and makes me map them to something.
Am I missing something, I don't want API gateway transforming my request I just want it to proxy it back to my internal REST endpoints.
FYI I am using a swagger doc to generate the API Gateway structure (their UI is quite annoying)
I read about {proxy+} endpoints which sound like what I want, but how do I define swagger docs about a certain endpoint action, or have granular apikey and authorizors on my endpoints?
You can set authorization only for resources and methods
. For example, we have the following API structure:
/
/test
GET (1)
PUT
/test/new (2)
ANY
/example/{proxy+}
GET (3)
1) For method
site.com/test endpoint
in GET method if you try to use the same key in PUT method you cath error.
2) For resource
site.com/test/new endpoint
in all methods in /test/new, but if you try to GET on /test/new/new2 you cath the error.
3) For resource(with proxy)
site.com/example/{proxy+} endpoint
You can auth to any example/* path.