aws-amplify / aws-amplify/amplify-hosting

Next js amplify 404 error in index.tsx file

Open
#3,512 0 comments 0 reactions 0 assignees View on GitHub
bug Next.js pending-triage redirects
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
![Screenshot 2023-06-04 112934](https://github.com/aws-amplify/amplify-hosting/assets/13625035/f3d24129-fd83-4a21-bc93-12bf390572a3)

Contributor guide

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.