Skip to content

Documentation : Working configuration for Angular 17 SSR #139

@ebiton-eig

Description

@ebiton-eig

To use iisnode with an Angular 17 SSR application, follow these steps:

Install the latest versions of iisnode and node.js.
By default, iisnode cannot handle .mjs files. To overcome this problem, change the last line of the interceptor.js (C:\Program Files\iisnode) file to :

require('child_process').spawn(process.argv[0], process.argv.slice(1));

Copy all the files in the dist folder into the directory that will serve your application.

Create a web.config file at the rout of this directory with the following contents:

<configuration>
  <system.webServer>

    <handlers>
      <add name="iisnode" path="server/server.mjs" verb="*" modules="iisnode" />
    </handlers>

    <rewrite>
      <rules>
        <rule name="StaticFiles" stopProcessing="true">
          <match url=".*\.(css|jpg|png|gif|js|ico|html|svg|json|woff|woff2|ttf|webp|webmanifest)$" />
          <action type="Rewrite" url="browser/{R:0}" />
        </rule>
        <rule name="DynamicContent">
          <match url="/*" />
          <action type="Rewrite" url="server/server.mjs" />
        </rule>
      </rules>
    </rewrite>
    
  </system.webServer>
</configuration>

Your Angular 17 SSR application should be well served!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions