Question

Running Next.js as web service on DO App Platform

Posted December 1, 2020 2.1k views
Node.jsReactDigitalOcean App Platform

I’m currently deploying my Next.js app as a web service on the DO App Platform, because I want to take advantage of some Next.js features like SSR and the new Image component that would require a running node server. Are there any cons to this approach that I should be aware of?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
2 answers

Hi @ilonews,

That’s definitely a valid approach to running a Next.js app! Service components also enjoy the same benefits as Static Site components by being behind the Cloudflare CDN.

One thing to keep in mind is that you can make use of caching on the Cloudflare CDN edge by setting the Cache-Control HTTP Headers on your Next.js server.

  • Thanks @kamaln7 ! That’s hugely helpful. A quick follow up: My next.js app gets data from a CMS and needs to rebuild static assets when updates are made. I’m doing that right now by sending a POST request to https://api.digitalocean.com/v2/apps/{MY_APP_ID}/deployments as per the API. I’ve found, however, that if I don’t use force_build then edits to the content that don’t add a new commit won’t trigger a rebuild in DO. Have I understood correctly that I have to use force_build for this?

    • No problem! Yes, that’s correct—this is actually one of the use cases that inspired the force_build option.

      App Platform reuses previous builds if it determines that nothing has changed since. Since there are no changes made to the git repo, only the content that’s in the CMS, you need to force a rebuild.

      We’re also exploring “Deploy URLs” which would be unique API endpoints dedicated to triggering deployments that you can use with CMSes without giving them access to any other operations.

Show answer This answer has been marked as resolved by ilonews.