When deploying a Next.js standalone build to cPane | Source: BlogForgeTM
16px
When deploying a Next.js standalone build to cPanel, data changes after revalidation might not be reflected due to caching or how the server handles file updates. Here's how to address this:
Verify Standalone Output:
Ensure your next.config.js file has output: 'standalone'. After building, confirm that the .next/standalone folder contains server.js, necessary dependencies, and the public and .next/static folders. If these folders are missing, manually copy them to the standalone directory.
Check cPanel Setup:
In cPanel, when setting up the Node.js application, ensure the "Application root" is correctly pointing to the directory containing your server.js file (usually within public_html). The "Application startup file" should be server.js.
Restart Node App:
After deploying or making changes, restart the Node.js application in cPanel. This ensures the server picks up the latest build and data. Sometimes, you may need to stop the application, run npm install again, and then restart it.
Bypass Cache:
If data is still not updating, it could be due to server-side caching. In your next.config.js, you can add headers to prevent caching:
if u uploaded it in cpanel with ISR then must add
export const dynamic = 'force-dynamic'; in the page.tsx
0 Comments
You must be to post a comment.