I have a NextJS app without an integrated api that I want to deploy to Vercel. It works fine when I run it locally yarn run dev
and I can also build it yarn run build
without any errors. When I deploy it Vercel, however, I receive a 404 Error
.
Here is my folder structure:
app/
- components
- pages
- editor
- [id].tsx
...tsx
- public
- utils
- db
api.ts
I am using NextJs 10.0.3.
Here is a link to the deployed app.
I don't have a nextjs config file. My assumption is that the error is caused by the dynamic route but I can't find my mistake. Also, no page is working when the app is deployed as opposed to only the dynamic page.
Do you have pointers on where to look next?
EDIT 1:
Here is a link to the GitHub repo.
EDIT 2: I found an issue but don't know how to fix it.
This is how my build output looks like on Vercel:
This is how it's supposed to look like on Vercel:
Not sure why the whole _next
folder is missing.
And the 404 error is returned by Vercel because they don't recognize that subdomain.
Vercel CLI automatically detects the framework your project is using. After the initial step, you can run the vercel command again to create a Preview Deployment. To create a Production Deployment, use the vercel --prod command. Making a Production Deployment with the vercel command.
Vercel enables you to develop, preview, and ship every Next.js feature, without configuration. Developed by the team behind Next.js, Vercel will automatically support every Next.js feature, forever. Vercel takes the zero-configuration mentality of Next.js to the cloud, so you can deploy your app in seconds.
The deep integration between Next.js and Vercel’s Edge Network allows you to preview, test, and deploy your app without worrying about infrastructure. Performance optimizations built into Next.js are automatically supported and enhanced on Vercel, creating smooth, interactive experiences that feel instant for every user.
For other errors, you can do the exact same thing with an _error.js file in the pages/ directory! The 404 error is special because it is always statically generated, but the others rely on the server. If you'd like to use the server-rendering aspects of Next.js on Netlify, check out our one-click install build plugin.
On development mode (local machine) everything works fine. Both static and dynamic routes are working properly and fetching data from the dontnet core Web API. However, when publishing the Nextjs app following this steps:
I just had this exact same issue. I have my Next app in a sub directory. I think that might be the cause of some problems.
What worked for me was.
Edited
Try to deploy using
now --prod --force
The --force
flag will clear your build cache (in production) and force production push.
If still no working then make sure to add now.json
Go to Project Settings
Change Framework preset from Other
to Next.js
Redeploy the project.
Also make sure to choose Next.js as Framework preset (and not other). You can find that in Project settings and under Build & Development Settings. More here: https://vercel.com/docs/concepts/deployments/build-step
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With