-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Publish nextjs failed #1388
Comments
Hi @jieliu218 currently, Amplify does not natively support deploying NextJS Apps, however it is on our roadmap for this year. In the meantime, here is a workaround for you (we will be updating our docs with this as well, but I wanted to provide it here to unblock you. Thanks! Steps
version: 1
backend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- amplifyPush --simple
- npm run build
- aws s3 mb s3://<bucket-name>
- aws s3 sync "s3://<bucket-name>/${USER_BRANCH}/.serverless" .serverless # pull previous state
- npx serverless # generate new & deploy!
- aws s3 sync .serverless "s3://<bucket-name>/${USER_BRANCH}/.serverless" # push state to bucket
frontend:
phases:
build:
commands:
- echo "nextjs app, skipping"
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
mynextjsapp:
component: "@sls-next/[email protected]"
amplify init
# enter a name
# enter an environment name
# enter default editor
# enter `javascript`
# enter `react`
# enter `src`
# enter `build`
# enter `npm run-script build`
# *enter `npm run dev` Now, select your AWS profile to deploy to and wait for the app to be created.
|
Hi @Athena96, I tried above steps, but getting issue with graphql api auth, the issue was with next build command
I got the same error message by follow steps from here I'm using next js with dynamic route + ssg, fetch all the ids from appsync not datastore.
===== I also tried with SSR (getserversideprops), but the issue now is with next export, it's not supported Any idea how to publish Next.js project with dynamic route on Amplify? Thanks, |
Issue fixed by not using getStaticPaths, getStaticProps & getServerSideProps, just use useRouter() to change the state without fetching data, fetch data done inside useEffect(). Thanks, |
Hi I'm having an issue that may be related to this: serverless-nextjs/serverless-next.js#936 @Athena96 is it possible this is related to the fix you're mentioning? I know I'm not deploying using Amplify, but perhaps you know something about this issue? |
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. |
Describe the bug
➜ nextjs git:(master) ✗ amplify publish
✔ Successfully pulled backend environment staging from the cloud.
Current Environment: staging
No changes detected
Publish started for amplifyhosting
info - Creating an optimized production build
info - Compiled successfully
info - Collecting page data
info - Generating static pages (2/2)
info - Finalizing page optimization
Page Size First Load JS
┌ ○ / 3.44 kB 65.8 kB
├ └ css/c39b4881d3c06665c5d4.css 760 B
├ /_app 0 B 62.4 kB
└ ○ /404 3.44 kB 65.8 kB
├ chunks/f6078781a05fe1bcb0902d23dbbb2662c8d200b3.7cd962.js 12.8 kB
├ chunks/framework.9116e7.js 41.8 kB
├ chunks/main.38b51b.js 6.54 kB
├ chunks/pages/_app.0536e9.js 529 B
├ chunks/webpack.e06743.js 751 B
└ css/2f26bb9842d84a608fa3.css 202 B
λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
○ (Static) automatically rendered as static HTML (uses no initial props)
● (SSG) automatically generated as static HTML + JSON (uses getStaticProps)
(ISR) incremental static regeneration (uses revalidate in getStaticProps)
✔ Zipping artifacts completed.
✖ Deployment failed! Please report an issue on the Amplify Console GitHub issue tracker at https://github.com/aws-amplify/amplify-console/issues.
An error occurred during the publish operation
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: