Hi,
I’ve been following the guide on making redirects work for troubleshooting and debugging as per the instructions found here.
My project uses Next.js 14, and for redirects, I have a _redirects
file set up with the following rule:
/form/* https://redacted.execute-api.redacted.amazonaws.com/:splat 200!
The intent is to proxy an API request to an AWS API Gateway url
To ensure the _redirects
file is included in the build output, I use the build command: "npm run build && cp _redirects .next/_redirects"
. After deploying, the Deploy Summary indicates that the rule is processed. However, I don’t see the _redirects
file in the Netlify Deploy file browser. Instead, a netlify.toml
file is generated with an equivalent redirect rule as the first entry among other auto-generated redirects.
Here’s the generated netlify.toml
entry:
[[redirects]]
from = "/form/*"
to = "https://redacted.execute-api.redacted.amazonaws.com/:splat"
status = 200
force = true
In my Next.js app, for submitting forms, I have the following code setup on the /contact
page:
const url = '/form/submit';
try {
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(dataToSubmit),
});
}
However, when testing the form submission, the request appears to call to https://mydomain/contact
instead of https://mydomain/forms/submit
and returns a 404 Not Found error, as seen in the browser’s DevTools.
I’ve spent a couple of days troubleshooting without success, and have looked through the recommended similar issues in the support forums or the chat bot. I would greatly appreciate any insights or suggestions on what I might be missing.
The netlify site is: govcraftweb.netlify.app
The working domain with SSL is: www.govcraft.ai
Thank you!