Questions tagged with Amazon API Gateway

Content language: English

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

1
answers
0
votes
37
views
asked a month ago

HTTP API, ALB integration 5XX errors

Hi, I have below setup as I followed following tutorial : https://aws.amazon.com/blogs/compute/configuring-private-integrations-with-amazon-api-gateway-http-apis/ customdomain (my.domain.com) -> HTTPAPI -> VPC Link -> ALB -> ECS VPCLink: - VPC for ALB is used - Subnets for ALB are added - Security groups for ALB is added Integration: - ALB is selected - 443 HTTPS Listener is selected - VPC Link is selected Paramater Mapping for Integration: - path -> overwrite -> $request.path Routing: "ANY /{proxy}" route is added and integration is attached. Deployment: - "prod" stage is created, auto-deploy is enabled Route53: Domain (my.domain.com) is added as an A record pointing to custom domain When I make request using my.domain.com (same if I use auto generated stage url) I always get 503 errors. I checked and ECS instance is running properly and healthy. Sample access log : { "requestId": "Z6KDRhh0DoEEJhg=", "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "sourceIp": "my_ip", "requestTime": "12/Oct/2022:20:29:34 +0000", "requestTimeEpoch": "1665606574", "httpMethod": "GET", "path": "/", "status": "503", "protocol": "HTTP/1.1", "responseLength": "33", "domainName": "my.domain.com", "integrationError": "-", "integrationDotError": "-", "integrationStatus": "200", "integrationDotStatus": "-", "integrationDotIntegrationStatus": "200", "integrationLatency": "9001" } What am I missing? Please help.
2
answers
0
votes
36
views
asked 2 months ago

API Gateway unable to stream back generated PDF due to encoding type

**I have posted updates below as I have gone through troubleshooting and bug fixing in regards to this problem.** I have a simple application that I have built that runs perfectly locally. A React front-end that takes some text inputs, and an Express backend that generates a PDF with the information, and streams back a PDF that is generated. The whole application works fine, as does testing a locally running as well as specifically hitting the endpoints using Insomnia running locally. The front-end is currently deployed in an S3 bucket being served through Cloudfront and is working fine. If I point an API request with Insomnia at my deployed API, the GET requests works fine, returning exactly what is expected, displaying the generated PDF in the content window. However when I make my POST request, I get some mixed messages. If I hit the POST in Insomnia I get back a 200, but the PDF that is returns is blank even though I verified that it did receive the POST body. If I use the deployed UI or my local UI pointing at the deployed API, I get a combination of errors. * Access to fetch at 'API ENDPOINT URL' from origin 'MY UI ORIGIN' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status. * POST 'API ENDPOINT URL' net::ERR_FAILED * Uncaught (in promise) TypeError: Failed to fetch The second errors feel like false flags caused by possibly the first error. However I have CORS Enabled in my API Gateway and currently am allowing wildcarded access. And the GET request works fine. I also have enabled 'application/json' and 'application/pdf' in the Binary Media Types in the Gateway settings. I saw some posts from a few years ago indicating that API Gateway doesn't support streaming back a file but I am unsure if that is correct. If so, that means I need to come up with a different solution for serving up generated files to end users. Or if that has been changed, there is another error in my AWS implementation. **UPDATE**: I made some progress. For testing, I actually removed the OPTIONS method from my API Gateway. That actually removed the CORS errors, which was unexpected. The GET request stills functions as it did before and all responses come back as 200. However the PDF is malformed or corrupted. It still works locally, but the PDF coming back from the deployed API does not. I also get the same result from the Test function within API Gateway but can confirm it still works running locally. **UPDATED PROGRESS**: After removing the rest of what appeared to be false flag errors, it has come down to API Gateway having challenges with encoding type. After making sure to have binary types being set within the API Gateway, within my code base, and having Accept headers set on the client, the returned document still appears to be encoded improperly. That is where this question is at now, as I continue to work on it.
2
answers
0
votes
48
views
profile picture
asked 2 months ago