I’m trying to use IIS with a Node.js API, and I’ve configured URL rewriting in my web.config file to handle API requests and Angular routes. The rewrite rules work perfectly for HTTP requests, but WebSocket requests don’t seem to be working. Additionally, I’m trying to use SSL.
Here is the web.config configuration I’m using:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="API Route" enabled="true" stopProcessing="true">
<match url="^api/(.*)$" ignoreCase="true" />
<action type="Rewrite" url="http://localhost:3002/{R:1}" logRewrittenUrl="true" />
</rule>
<rule name="Angular Routes" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="./index.html" />
</rule>
</rules>
</rewrite>
<staticContent>
<mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
<clientCache cacheControlMode="DisableCache" />
</staticContent>
</system.webServer>
</configuration>