Guide on deploying Angular 9 SSR app on Internet Information Services

After upgrading my Angular 7 project to Angular 9, I successfully executed the commands "ng add @nguniversal/express-engine", “npm run build:ssr" and "npm run serve:ssr” in my local environment. The deployment to IIS on the web server created a "dist" folder containing "browser", "server" folders, and a web.config file.

The issue arises when the IIS website points to the "dist" folder but encounters an HTTP 500 error upon execution. The provided web.config file directs to the "server/main.js" file, causing the problem.

I require assistance in properly deploying the "dist" folder to IIS on the web server.

web.config


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.webServer>        
        <webSocket enabled="false" />
        <handlers>
            <add name="iisnode" path="server/main.js" verb="*" modules="iisnode" />
        </handlers>
        <rewrite>
            <rules>
                <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
                    <match url="^server.js\/debug[\/]?" />
                </rule>
                <rule name="StaticContent">
                    <action type="Rewrite" url="public{REQUEST_URI}" />
                </rule>
                <rule name="DynamicContent" stopProcessing="true">
            <match url=".*" />
                    <conditions>                        
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="server/main.js/{R:0}"  />
                </rule>
            </rules>
        </rewrite>
        <security>
            <requestFiltering>
                <hiddenSegments>
                    <remove segment="bin" />
                </hiddenSegments>
            </requestFiltering>
        </security>
        <httpErrors existingResponse="PassThrough" />
        <iisnode nodeProcessCommandLine="C:\Program Files\nodejs\node.exe"
            watchedFiles="web.config;*.js" 
            node_env="%node_env%" 
            loggingEnabled="true" 
            logDirectory="iisnode" 
            debuggingEnabled="true" 
            maxLogFileSizeInKB="1048" 
            maxLogFiles="50" 
            devErrorsEnabled="true" />
    </system.webServer>
</configuration>


Answer №1

To construct the application, utilize the subsequent command. build:client-and-server-bundles

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using the concat operator along with the if statement in Angular to make sequential requests based on certain conditions

Managing multiple HTTP requests in a specific order is crucial for my event. To achieve this, I am utilizing the concat operator from rxjs. For instance, upon receiving data from the first request, I update local variables accordingly and proceed to the ne ...

Angular2 - Breaking down applications into reusable components

Utilizing custom properties permits seamless data binding between multiple components. <section id="main"> <app-home [dict]="dict">Hello there!</app-home> </section> In this scenario, dict serves ...

Retrieve the data set's value upon clicking the button

In this HTML snippet, I am looping over a data set. Upon clicking the button, I aim to retrieve a specific value, such as the id from the data set for use in my TypeScript file. <div *ngFor="let item of assignmentlist; let i = index"> < ...

Combine two Observable arrays into a single array and showcase their contents using ngFor within an Ionic 3 application

In my Ionic 3 project, I am fetching two arrays through API calls. My goal is to display the data from both arrays in the same line like this: [item1.1] [item2.1] [item1.2] [item2.2] [item1.3] [item2.3] Instead of displaying them like this: [item1.1] ...

I need to display the Dev Tools on an Electron window that contains multiple BrowserViews. Can anyone advise on how to achieve

My Electron Browserwindow is utilizing multiple BrowserViews to embed web content into the window. These BrowserViews are set based on the tab selected within the window. I can easily open the dev tools for these individual BrowserViews (opening in separ ...

Tips for converting a date string to a date object and then back to a string in the same format

I seem to be encountering an issue with dates (shocker!), and I could really use some assistance. Allow me to outline the steps I have been taking. Side note: The "datepipe" mentioned here is actually the DatePipe library from Angular. var date = new Dat ...

angular pipe and tap methods fail to execute the designated function

I am encountering a problem when calling a function in my login service. I have tried using a pipe and tap. Interestingly, when I use res => console.log(res), it outputs the desired result. However, when I attempt to call a function, it seems that the ...

Tips for identifying MIME type errors in an Angular 9 application and receiving alerts

While working on my Angular app, I encountered the MIME type error Failed to load module script: The server responded with a non-javascript mime type of text/html. Fortunately, I was able to resolve it. Now, I'm stuck trying to figure out how to rece ...

Troubleshooting Angular 6: Issues with Route Guards not functioning as expected

Striving to enhance frontend security by restricting access to specific IDs. The goal is to redirect anyone trying to access routes other than /login/:id to a page-not-found error message if not already logged in, but encountering some issues. Below are t ...

Encountering issues with obtaining tokens silently using Angular and Microsoft MSAL, resulting in errors AADB2C90077 and AADB2C90205

Seeking assistance in retrieving a token from AAD B2C configuration using Angular9 and microsoft/msal My module setup is as follows; MsalModule.forRoot( { auth: { clientId: "xxxxxxxxxxxxxxxxx", ...

Having trouble locating node_modules post deployment?

Although the title may lead you astray, please stay with me for a moment. I've created a basic Angular2 application in Visual Studio 2015 and have now deployed it to Azure. While having node_modules in the development environment worked perfectly fi ...

Deploying Angular to a shared drive can be done in a

My angular.json file contains the following line: "outputPath": "Y:\Sites\MySite", After running ng build, I encountered the error message: An unhandled exception occurred: ENOENT: no such file or directory, mkdir 'D:& ...

Is it just me, or does the this.router.subscribe method no longer exist in Angular 2's @angular/router library?

I'm experiencing an issue in Angular 2 with the library @angular/router. It appears that the method this.router.subscribe no longer exists. Previously, this code worked fine on an older version of the router that has since been deprecated. Does anyon ...

CSS-WHAT Package for Angular Update - Enhance Your Styles!

In my Angular setup, the configurations are as follows: _ _ ____ _ ___ / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _| / △ \ | '_ \ / _` | | | | |/ _` | '__| | | ...

How can I enable editing for specific cells in Angular ag-grid?

How can I make certain cells in a column editable in angular ag-grid? I have a grid with a column named "status" which is a dropdown field and should only be editable for specific initial values. The dropdown options for the Status column are A, B, C. When ...

The compatibility issue between the text-mask library and the Angular material datepicker is causing functionality problems

I am currently utilizing the text-mask library (https://www.npmjs.com/package/angular2-text-mask) in an attempt to integrate it with two Angular datepicker components. The functionality works as expected when manually entering the date into the input field ...

Generate a TemplateRef and place it into the template of the component

Inquiring about Angular 5.0.2 After reviewing the example provided on NgTemplateOutlet at https://angular.io/api/common/NgTemplateOutlet I am eager to discover if there is a method to dynamically generate a TemplateRef and then insert it into the componen ...

There was an issue retrieving the metadata for the bootstrap package using the git+ssh protocol

While attempting to install angular devkit and other dependencies using npm install, I encountered the following error message: Could not retrieve metadata for bootstrap@git+ssh://example@example.com/gios/Web-Standards-Bootstrap.git#05a343dddce91dd157702 ...

The rendering of HTML is not supported by Next.js SSR

I'm a bit confused about how Next.js SSR works. On my index page, I've used getServerSideProps, so I expected the page to be prerendered as HTML. However, it seems to only render a single div, a JSON object, and the Next.js scripts, with the page ...

Tips for assigning an external variable using Angular RxJS map function?

I am currently working on making code more reactive and declarative by using the async pipe to update the template. I'm facing a challenge with changing a variable that was previously set in the subscribe() method. Updating this variable from the map ...