aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
461 stars 116 forks source link

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

Open Preethi0499 opened 11 months ago

Preethi0499 commented 11 months ago

Before opening, please confirm:

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

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

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

city-kim commented 10 months ago

In my case, I used next.js in all my monorepo projects, so I included next, react, and react-dom dependencies in the package.json file in root, but not in the package.json in the apps subdirectory.

I added them back to each app's package.json and deployed it, and it worked.

diegomejiaio commented 3 months ago

same issue