aws-amplify / aws-amplify/amplify-hosting

After deploying Next.js SSR from AWS Amplify getting 404 error

Open
#3,870 8 comments 2 reactions 0 assignees View on GitHub
pending-triage
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

Redirects, SSR

### Frontend framework

Next.js

### Next.js version

13.5.4

### Next.js router

App Router

### Describe the bug

My code is in specific folder . I have written the amplify.yml with specific "appRoot" directory.Even though my build and deploy get succeeded , when accessing I am getting 404 page not found

After building and deploying this is the error

![Screenshot from 2023-12-21 13-06-41](https://github.com/aws-amplify/amplify-hosting/assets/81558566/57284866-e6d9-4f6c-95a1-d68ae54fca94)

### Expected behavior

If we are specifying appRoot path it should pick up the pages from the specific path of .next, but it is not taking

### Reproduction steps

Put the code in a specific path and specific the appRoot path in amplify.yml . After that build and deploy and access the url

### Build Settings

```yaml
This is my amplify.yml
version: 1
appRoot: src/ui
frontend:
phases:
preBuild:
commands:
- ls
- pwd
- npm ci
- ls
build:
commands:
- npm run build
postBuild:
commands:
- ls
- pwd
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
```

### Log output

This staging.d3qoyhgf3tt33g.amplifyapp.com page can’t be foundNo web page was found for the web address: https://staging.d3qoyhgf3tt33g.amplifyapp.com/

### Additional information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the reported amplify.yml, especially appRoot: src/ui and the .next artifacts baseDirectory, then compare the successful build output with the deployed root URL in the issue. Done means a Next.js 13.5.4 App Router deployment using this layout loads the application instead of returning a 404.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, next.js
Domain
ci-cd, cloud, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.