Hi Vinh Nguyen
Welcome to the Microsoft Q&A Platform!
The error is Error 500.1013 - Internal Server Error, suggests that there is an issue with your Azure Web App configuration when deploying your Next.js application using iisnode
.
Verify Deployment Structure. Build your Next.js app locally.
npm run build
check the following directories/files are deployed properly .
.next
node_modules
package.json
Any custom server.js
or index.js
file
Use this web.config
template.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="DynamicContent">
<match url=".*" />
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
<iisnode watchedFiles="web.config;server.js" />
</system.webServer>
</configuration>
Replace server.js
with the actual entry point of your application.
Ensure server.js
or Entry Point is Correct .
server.js
for Next.js.
const { createServer } = require('http');
const next = require('next');
const app = next({ dev: false });
const handle = app.getRequestHandler();
app.prepare().then(() => {
createServer((req, res) => {
handle(req, res);
}).listen(process.env.PORT || 3000);
});
Add PORT
environment variable ( 3000
).
Set WEBSITE_NODE_DEFAULT_VERSION
to a compatible Node.js version (18.x
).
Ensure the wwwroot
directory grants read/write permissions to the Application Pool Identity.
Enable .NET Extensibility 4.x
.
Ensure iisnode
is installed and configured correctly.
Open IIS Manager > Select Your Site > Add Failed Request Tracing for 500 errors.
Analyze logs for more details.
ref: Azure Web App Node.js Documentation
Failed Request Tracing in IIS
If this doesn't resolve the issue, please share additional logs or configuration details for deeper analysis.
If the answer is helpful, please click "Accept Answer" and kindly upvote it.