If you host an Angular application on Microsoft Azure you probably want to define a mimemap for .json and .woff / .woff2 files to get rid of the console errors. Also in order to enable client side routing we have to add a rewrite rule.
This is how my web.config looks like:
<configuration> <system.webServer> <staticContent> <mimeMap fileExtension=".json" mimeType="application/json" /> <remove fileExtension=".woff"/> <mimeMap fileExtension=".woff" mimeType="application/font-woff" /> <mimeMap fileExtension=".woff2" mimeType="font/woff2" /> </staticContent> <rewrite> <rules> <rule name="Angular" 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="/" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
To ensure the config gets deployed, put it in the src directory:
And add it to list of assets within the .angular-cli.json:
Hi there.
I am using IIS to deploy an Angular application.
I noted that after ng build, when I try to use in production that application/x-www-form-urlencoded data is removed from header. The api receives a json empty. In development the api receives normally. Is it a web.config issue? Do you know how can I fix it?
LikeLike
Hi Heber,
sorry, I can’t help you with that issue. You could post a reproducible sample on stackoverflow – I am sure there are people who can help you with that.
Cheers
Martin
LikeLiked by 1 person
Good information It saved my day
LikeLike
The webconfig in the post appears empty to me
LikeLike
Thanks for the hint. I fixed it.
LikeLike