getting 404 after fresh deploy to pages

When I run the next.js app locally I have no problems but on pages I get 404 for all pages that work locally
15 Replies
shapeshifter
shapeshifterOPβ€’2y ago
not using next-on-pages, building using next build and output directory I left empty
James
Jamesβ€’2y ago
If you're not using next-on-pages, you need to do a static export, next export, instead of next build.
shapeshifter
shapeshifterOPβ€’2y ago
Ok, I switched from next-on-pages because it was having an issue with start up time. Not using any SSR or edge route capabilities right now so I switched over the startup time error is usually because too much is in the global scope for the script to start correct? Not going to go troubleshoot it right now but just something to figure out in the future if we find ourselves there
James
Jamesβ€’2y ago
Indeed. There is some work being done in this area - you can read more and track the issue at https://github.com/cloudflare/next-on-pages/issues/54
shapeshifter
shapeshifterOPβ€’2y ago
I'm getting this error when i try to do next export 17:15:43.783 Error: Could not find a production build in the '/opt/buildhome/repo/.next' directory. Try building your app with 'next build' before starting the static export. https://nextjs.org/docs/messages/next-export-no-build-id 17:15:43.783 at /opt/buildhome/repo/node_modules/next/dist/export/index.js:63:19
shapeshifter
shapeshifterOPβ€’2y ago
should i add something in package.json to "next build && next export"?
James
Jamesβ€’2y ago
Yeah, sorry, you need to run both commands
shapeshifter
shapeshifterOPβ€’2y ago
No sorry necessary, you've gone above and beyond to help me out today and I really appreciate it
James
Jamesβ€’2y ago
πŸ™‚
shapeshifter
shapeshifterOPβ€’2y ago
hahahah I thought I wasn't going to have to explore troubleshooting to make next-on-pages work buuuuuuut I forgot about the image optimization api not being available with next export
James
Jamesβ€’2y ago
It's also not available with next-on-pages πŸ™ˆ. You can use Cloudflare's image optimization/resizing product with a custom loader for next/image either at the next.config.js-level, or the component-level.
shapeshifter
shapeshifterOPβ€’2y ago
I see the docs on the component level but. I don't see them on the next.config.js level
James
Jamesβ€’2y ago
Next.js by Vercel - The React Framework
Production grade React applications that scale. The world’s leading companies use Next.js by Vercel to build static and dynamic websites and web applications.
shapeshifter
shapeshifterOPβ€’2y ago
Thank you fixed the image loader but and I'm running a command of "next build && next export" from my package.json and still getting 404's I figured it out! @5927 you have been an absolute rockstar today and I know I said it before but I really really appreciate your help
James
Jamesβ€’2y ago
Glad to hear, and my pleasure πŸ˜„
Want results from more Discord servers?
Add your server