Running Next.js on Azure App Services
Originally published at https://fek.io.
How to run your Next.js app on Azure
I recently gave a presentation on building universal apps using Next.js and Express.js. Next.js is a framework from the great people at Vercel.
Vercel is a great hosting platform, but I am working on a project that is already using resources on the Azure platform, so I decided to host it there instead of at Vercel or another platform as a service.
I ran into a problem when I tried to deploy my Next.js app on Azure App Services. Azure already provides a several ways of deploying apps using continuous integration through git repos. You can configure your app service to pull from your repo every time a change is pushed. The problem is that you have to specify a port
. Here is how you can configure a port
in your code and package.json.
The express part of your express app needs to be able use port provided Azure. Make the following change to your Express app;