aws-amplify / aws-amplify/amplify-hosting
Next js amplify 404 error in index.tsx file
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
### Before opening, please confirm:
- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-hosting/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-hosting/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-hosting/blob/master/CONTRIBUTING.md).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
### App Id
NEW_APP
### AWS Region
ap-southeast-1
### Amplify Hosting feature
Deployments, Redirects
### Describe the bug
I've managed to deploy the nextjs app in Amplify.
But for the landing page (index.tsx) and child pages ended with index.tsx, throws the 404 error.
But for routes with any other name works fine.
Locally, the build works fine. I suspect this has to do with setting up redirects
working
- pages/search.tsx
- pages/review/review.tsx
not working
- pages/index.tsx
- pages/business/index.tsx
versions
"next": "^13.0.4",
### Expected behavior
The landing page needs to render index.tsx content
### Reproduction steps
"build": "next build",
"start": "next start",
### Build Settings
```yaml
version: 1
frontend:
phases:
preBuild:
commands:
- rm -rf node_modules -rf yarn.lock && yarn install --frozen-lockfile
build:
commands:
- yarn build
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
```
### Log output
```
# Put your logs below this line
```
### Additional information
redirects

Contributor guide
Research direction
Start by reproducing the Amplify deployment using the supplied build settings and inspect the configured redirects. Compare the deployed behavior of pages/index.tsx and pages/business/index.tsx with pages/search.tsx and pages/review/review.tsx, then verify that the landing page and nested index route render successfully without 404 responses.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, next.js
- Domain
- cloud, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100