Next.js Discord

Discord Forum

public folder on Amplify

Unanswered
Rainbow trout posted this in #help-forum
Open in Discord
Rainbow troutOP
Hi there,

I have deployed my SSR nextjs application to Amplify, which works! However, I have set the baseDirectory to the .next folder, which I think is the reason my public folder isn't being deployed? When I go to my app's /manifest.json it returns a 404.

When I set the baseDirectory to a file higher, it won't be able to find the files in the .next folder and the pipeline fails. So I think the baseDirectory needs to be .next .
How is this usually solved with deployments on platforms other than Vercel?

amplify.yml
version: 1
applications:
  - appRoot: .
    frontend:
      phases:
        preBuild:
          commands:
            - npm ci
        build:
          commands:
            - npm run build:css
            - cd workspaces/dashboard
            - npx next build
      artifacts:
        baseDirectory: workspaces/dashboard/.next
        files:
          - '**/*'
      cache:
        paths:
          - node_modules/**/*

PS. Don't really know if this is nextjs or amplify related? :)

Thanks in advance!

2 Replies

Rainbow troutOP
Hi, any response would be greatly appreciated
Rainbow troutOP
Hi, I've been abl to get it working using this config:

version: 1
applications:
  - appRoot: workspaces/dashboard
    frontend:
      phases:
        preBuild:
          commands:
            - cd ../..
            - npm ci
        build:
          commands:
            - npm run build:css
            - cd workspaces/dashboard
            - npx next build
      artifacts:
        baseDirectory: .next
        files:
          - '**/*'
      cache:
        paths:
          - node_modules/**/*

and using the monorepo option in Amplify, setting the app root to workspaces/dashboard as well