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
457 stars 115 forks source link

Not able to deploy Next.js SSR app #2641

Closed ikoichi closed 2 years ago

ikoichi commented 2 years ago

Before opening, please confirm:

App Id

d1sig4j0w4mc7r

Region

eu-west-1

Amplify Hosting feature

Build settings, Manual deploys

Describe the bug

I created an Amplify App using the CDK.

The Next.js app is inside a folder of the repository, called web-app.

As the Framework was not detected, I manually forced the Framework to Next.js - SSR with these commands.

aws amplify update-app \
--app-id d1sig4j0w4mc7r \
--platform WEB_DYNAMIC \
--region eu-west-1

aws amplify update-branch \
--app-id d1sig4j0w4mc7r \
--branch-name dev \
--framework 'Next.js - SSR' \
--region eu-west-1

The Service Role is set, it was created by the CDK, and I added to it the additional Permissions as specified in the guide https://docs.aws.amazon.com/amplify/latest/userguide/server-side-rendering-amplify.html#ssr-IAM-permissions

I am still getting this error in the deploy phase:

2022-03-11T10:09:23 [INFO]: Beginning deployment for application d1sig4j0w4mc7r, branch:dev, buildId 0000000007
2022-03-11T10:09:23 [INFO]: Cannot find any generated SSR resources to deploy. If you intend for your app to be SSR, please check your app Service Role permissions. Otherwise, please check out our docs on how to setup your app to be detected as SSG (https://docs.aws.amazon.com/amplify/latest/userguide/server-side-rendering-amplify.html#deploy-nextjs-app)
2022-03-11T10:09:23 [ERROR]: {"code":"7","message":"No ssrResources.json file"}

Expected behavior

Deployment to succeded, and CloudFront, Lambdas, S3 resources are created.

Reproduction steps

Manually run a build.

Build Settings

{
  "version": "1.0",
  "appRoot": "web-app",
  "frontend": {
    "phases": {
      "preBuild": {
        "commands": [
          "yarn"
        ]
      },
      "build": {
        "commands": [
          "npm run build"
        ]
      }
    },
    "artifacts": {
      "baseDirectory": ".next",
      "files": "**/*"
    },
    "cache": {
      "paths": [
        "node_modules/**/*"
      ]
    }
  }
}

Additional information

Thanks for your help!

github-actions[bot] commented 2 years ago

Hi :wave:, thanks for opening! While we look into this...

If this issue is related to custom domains, be sure to check the custom domains troubleshooting guide to see if that helps. Also, there is a more general troubleshooting FAQ that may be helpful for other questions.

Lastly, please make sure you've specified the App ID and Region in the issue!

calavera commented 2 years ago

hi @ikoichi, can you give us more information about your app? Which version of Next.js are you using?

ikoichi commented 2 years ago

Hi @calavera I'm using Next.js 12

calavera commented 2 years ago

thanks for letting us know @ikoichi, that's what I suspected. We currently don't support that version, we're working on it.

You can keep track of our progress by clicking the "Subscribe" button in this issue 👉 #2343

I'm going to close this ticket so we don't keep duplicated ticket around.

wottpal commented 2 years ago

@calavera do you have an official ETA for nextjs-12 support. would love to use aws for my app but vercel just has the better arguments atm.

moatezheni commented 2 years ago

some libs and files breake amlify framework detection for exemple next-pwa packege and all related config or files files that contain env variables and .githooks folder

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.