I am experiencing an issue with my Next.js application hosted on AWS Amplify where API requests to https://api-test.example.com/login fail due to a DNS resolution error (getaddrinfo ENOTFOUND). This issue does not occur in my local environment or in vercel.com, suggesting it's specific to the Amplify environment.
Expected behavior
The API request should successfully resolve the DNS and connect to the external service without encountering a getaddrinfo ENOTFOUND error and fetch response.
The API requests should consistently succeed without encountering 408 errors, similar to how they function in local and Vercel environments.
Reproduction steps
Host a Next.js application on AWS Amplify.
Make a POST request to an external API (https://api-test.example.com/login) from the application.
```
The API request fails with the following error:
{
"message": "Please try again!",
"details": {
"method": "POST",
"url": "https://api-test.example.com/login",
"message": "getaddrinfo ENOTFOUND api-test.example.com"
}
}
```
Additional information
Troubleshooting Steps Undertaken
Dynamic Routing Configuration:
Tried both with and without force-dynamic in the API route configuration. The issue persists regardless of this setting.
Build Image Changes:
Switched the build image to Amazon Linux 2023 and also tried a custom image (public.ecr.aws/docker/library/node:18.17.0). Neither change resolved the issue.
Custom HTTP Configuration:
Removed the custom HTTP configuration (customHttp.yml) to check its impact. The issue still occurred without this configuration.
Intermittent Behavior:
The API sometimes works but often returns a 408 timeout error. This behavior is inconsistent and only observed in the Amplify environment, not locally or on Vercel.
Build Image for Unit Tests:
Using Amazon Linux 2023 and the custom Node.js image was necessary for running unit tests, as they do not work with the default image.
Before opening, please confirm:
App Id
arn:aws:amplify:eu-central-1:392145163496:apps/du9vxmpr1v1e5
AWS Region
us-east-1
Amplify Hosting feature
Build settings, Custom build image, Custom headers, Deployments, Frontend builds
Frontend framework
Next.js
Next.js version
13.5.5
Next.js router
App Router
Describe the bug
I am experiencing an issue with my Next.js application hosted on AWS Amplify where API requests to
https://api-test.example.com/login
fail due to a DNS resolution error (getaddrinfo ENOTFOUND
). This issue does not occur in my local environment or in vercel.com, suggesting it's specific to the Amplify environment.Expected behavior
The API request should successfully resolve the DNS and connect to the external service without encountering a
getaddrinfo ENOTFOUND
error and fetch response.The API requests should consistently succeed without encountering 408 errors, similar to how they function in local and Vercel environments.
Reproduction steps
https://api-test.example.com/login
) from the application.Build Settings
Log output
Additional information
Troubleshooting Steps Undertaken
Dynamic Routing Configuration:
Build Image Changes:
Custom HTTP Configuration:
Intermittent Behavior:
Build Image for Unit Tests:
Custom HTTP Configuration (customHttp.yml):
Api Route