Next js deploy in cpanel

Zero
ZeroSpace (admin)

May 5, 2025, 02:48 PM

1 Min

195

0

0


Next js deploy in cpanel

When deploying a Next.js standalone build to cPane | Source: BlogForgeTM


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
Author

Zero Space

About admin

You should write because you love the shape of stories and sentences and the creation of different words on a page.

View All Posts (25)

0 Comments

Author image

You must be to post a comment.