Skip to content

Commit

Permalink
fix(iis): exclude static files from URL rewrite
Browse files Browse the repository at this point in the history
Updated the URL rewrite rule in `web.config` to ensure that certain static files,
including `manifest.json`, `.ico`, and image files, are not rewritten to `/`. This
change prevents the unintentional rewrite of these files, which can cause them to
not be served correctly.

Additionally, verified and ensured correct MIME types for static content, including
`application/json` for JSON files.

This should resolve issues with static resources not loading properly on IIS.
  • Loading branch information
SjoenH committed May 6, 2024
1 parent 181b2c4 commit 6ed0e8a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kabinizer-front-end/public/web.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
<rule name="React Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<!-- Exclude known static files from rewrite -->
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<!-- Exclude JSON and other specific static resources from rewrite -->
<add input="{REQUEST_URI}" pattern="\.json$" negate="true" />
<add input="{REQUEST_URI}" pattern="\.ico$" negate="true" />
<add input="{REQUEST_URI}" pattern="\.png$" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
Expand All @@ -23,4 +28,4 @@
<mimeMap fileExtension=".ico" mimeType="image/x-icon" />
</staticContent>
</system.webServer>
</configuration>
</configuration>

0 comments on commit 6ed0e8a

Please sign in to comment.