Something is broken with the Amplify Getting Started Nextjs tutorial found here: https://docs.amplify.aws/start/q/integration/next/ and I'm hoping to get some advise.
The problem occurs in the section called "API with Server-Side Rendering (SSR) where you are asked to copy in two sections of code into pages/_app.js and pages/index.js.
Incidentally, in order for this code to even be used, the tutorial skips an important point during the
npx create-next-app next-amplified
Step. Here it's important to answer "No" to the " Would you like to use TypeScript with this project? … No / Yes" prompt, that otherwise defaults to "Yes". Since the tutorial instructs the audience to insert javascript for these two pieces of code mentioned above, then "No" is the correct response here. Otherwise the default next welcome screen written in typescript will continue to be displayed.
At any rate, after inserting the code (one import added to _app.js, and the entire index.js file replaced), running
npm run dev
and hitting the url http://localhost:3000 with your browser.
The following error is displayed in the browser:
Server Error
Error: No current user
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
GraphQLAPIClass.<anonymous>
file:/home/chris/projects/amplify/amplify-nextjs-app/next-amplified/node_modules/@aws-amplify/api-graphql/lib/GraphQLAPI.js (243:31)
step
<home>/projects/amplify/amplify-nextjs-app/next-amplified/node_modules/@aws-amplify/api-graphql/lib/GraphQLAPI.js (44:23)
Object.throw
file:/home/chris/projects/amplify/amplify-nextjs-app/next-amplified/node_modules/@aws-amplify/api-graphql/lib/GraphQLAPI.js (25:53)
rejected
<home>/amplify/amplify-nextjs-app/next-amplified/node_modules/@aws-amplify/api-graphql/lib/GraphQLAPI.js (complete text in attached error log).
The console window in which the npm command is run shows a similar error:
Thank you very much for any advice you may have.