niclas-timm / laravel-nextjs-starter

A Starter Kit for applications with Laravel as the API and NextJS for the Frontend
308 stars 82 forks source link

I can't build the nextJs Code #28

Closed YnievesDotNet closed 3 years ago

YnievesDotNet commented 3 years ago

I have error when I run the command

npm run build

`$ npm run build

> client@0.1.0 build
> next build

Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
Loaded env from /Volumes/Data/public/client/.env.local
Failed to compile.

./pages/user/email/verify/[userID]/[hash].tsx:35:15
Type error: Argument of type '() => Promise<void>' is not assignable to parameter of type 'EffectCallback'.
  Type 'Promise<void>' is not assignable to type 'void | (() => void)'.
    Type 'Promise<void>' is not assignable to type '() => void'.
      Type 'Promise<void>' provides no match for the signature '(): void'.

  33 | 
  34 |     // Send api request to api upon mount of the component.
> 35 |     useEffect(async () => {
     |               ^
  36 |         const res = await props.verifyEmail(userID, hash, expires, signature);
  37 | 
  38 |         // Successfull verification.
info  - Creating an optimized production build .% 

How I can fix that?

Thanks

YnievesDotNet commented 3 years ago

Other think, I can put the code as JS only and publish static code, in the laravel public directory?

niclas-timm commented 3 years ago

Hi @YnievesDotNet , thanks for creating the issue :)!

I pushed a fix regarding your problems when running the build command. You can take the changes from the commit, but here is the gist of it:

The build should now work as expected.

Regarding your second question: As stated in the docs, the repo does currently not support static generation due to the way Next.js works. We're dealing with a lot of dynamic data and have to reload the user every time the page refreshes. This forces us to use getInitialProps in _app.tsx, which disqualifies us from SSG. For reference see here: https://nextjs.org/docs/api-reference/data-fetching/getInitialProps

Hope this helps!

Thanks again for reaching out and best regards, Niclas

YnievesDotNet commented 3 years ago

Now have "CSRF token mismatch." error when try register