cd ./dist/angular-ssr/server
node server.mjs
8. Stop the local server to release in-use files, archive the dist folder and its sub-items to .zip file
If you use other NodeJS packages in your project, you will also need to package the entire node_modules folder and upload it to the server
10. Unzip the .zip file to the target site path, i.e. site3
12. Change the content of site3/web.config file to
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" />
</handlers>
<httpPlatform processPath="node" arguments="./dist/angular-ssr/server/server.mjs" startupTimeLimit="20" startupRetryCount="2" stdoutLogEnabled="true" stdoutLogFile="./log.txt">
<environmentVariables>
<environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%" />
<environmentVariable name="NODE_ENV" value="production" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
The final folder structure should be like:
site3/
|-- dist/
|-- angular-ssr/
|-- browser/
...
|-- server/
|-- server.mjs
...
...
|-- web.config
13. Access your site URL to check the application
Troubleshooting(For IISNode Module Only)
Case 1: In Angular version 19, the <project-name>/src/server.ts file has been optimized and now includes a check to determine if this module is the main entry point. Despite following the previous steps, you might still encounter an HTTP 500 error with your Angular Universal app.
Solution: Modify your server.ts file and add a new condition to handle scenarios when the application is hosted on a production server with iisnode. Refer to the highlighted section in the code below. Afterward, follow the steps above to build your app and re-upload the files to your account.
/**
* Start the server if this module is the main entry point.
* The server listens on the port defined by the `PORT` environment variable, or defaults to 4000.
*/
if (isMainModule(import.meta.url) || process.env["APP_POOL_ID"]?.toLowerCase() === "iisnode") {
const port = process.env['PORT'] || 4000;
app.listen(port, () => {
console.log(`Node Express server listening on http://localhost:${port}`);
});
}