- Newest
- Most votes
- Most comments
Looks like you are missing a trailing slash in path_pattern try to add a slash.
ordered_cache_behavior { path_pattern = "/api/upload-url/"
What is the error code after you updated the trailing slash? do you have logs enabled on API Gateway? If yes please share the logs.
Also based on your code I hope you have configured your API Gateway to handle request on "/${var.api_stage}/upload_url/api/upload-url/" and not on "/api/upload-url/"
Also if you can share the cache_policy and origin_request_policy, it might be relevant.
i have access log turned on for api gateway, but it doesn't log these request but in the response header there apigatewayrequestid (check below) and i have configured the apigateway to accept post request on root so / and when i call it from postman it works (apigatewayid.execute-api.region.amazonaws.com/stage) stage being the name of the stage but ofc cloudfront is giving error 404 not found as for the caching policy it's manged caching policy so Managed-CachingDisabled and Managed-AllViewerExceptHostHeader
Value content-type application/json content-length 23 connection close date Thu, 13 Jun 2024 15:56:04 GMT apigw-requestid ZUB3MhdbDoEEJZw= x-cache Error from cloudfront via 1.1 93fa84206c30dc35b459d2b796c3a09c.cloudfront.net (CloudFront) x-amz-cf-pop HEL51-P5 x-amz-cf-id J3tKLbhlgI71qz4N1KlelVHkZmVmdEqMZz9EHuvFhk05UbZlIEXLew==```I think you need to configure API Gateway to accept the POST requests on path "/api/upload-url/"
also update the origin_path to "/" origin { origin_id = local.apigw_origin_id domain_name = local.apigw_domain_name origin_path = "/"
That should fix the 404 issue
I think the other response is correct about the exact URL path shown in the test request in the screenshot, but to be sure, if the intent is to allow all URLs with that prefix, you'll additionally need a trailing * wildcard. For example, /api/upload-url/* or api/upload-url/* (the leading slash is not required but it is allowed).
The path pattern syntax is explained in detail in this documentation article, but the short version is that * matches zero or more characters and ? matches exactly one character: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesPathPattern
Relevant content
- asked 2 years ago
- asked 3 years ago
- asked 8 months ago
- AWS OFFICIALUpdated 3 months ago

made the change, now at least the request goes to apigateway as this is what it returns in the response header