0

I'm working on an Angular 2 front-end on an ASP.NET 4.5 backend project. On this project I've configured a sort of wwwroot (thanks to this tutorial) pointing to my dist folder.

But since it's an Angular 2 project, I'm also redirecting everything to index.html page

    <rule name="AngularJS" stopProcessing="true">
      <match url="[a-zA-Z]*" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
        <add input="{REQUEST_URI}" pattern="^/oauth" negate="true" />
      </conditions>
      <action type="Rewrite" url="/" />
    </rule>

Now my problem is that since I added the PhysicalFileSystem, I can't retrieve my bundle file anymore. I'm requesting main.bundle.js (which is located in dist/main.bundle.js), which should be rightly retrieved thanks to the filesystem, but unlucky for me, it's catch by the RewriteRule and it just render me the index.html page.

How can I fix the priority of this?

TL;DR Redirecting everything to index.html, but also have a logical root folder under dist. Would like my server to retrieve everything from dist, but it fall under the RewriteRule since it's not physically present.

Community
  • 1
  • 1
LoïcR
  • 4,940
  • 1
  • 34
  • 50

1 Answers1

0

For those we were encountering the same issue, the problem was just coming from the fact that these file are not physically present, every request to them was redirect to the index.html.

To fix this little issue, I just added a little exception to my RewriteRule to handle the request to static file, which now make my system works!

<add input="{REQUEST_URI}" pattern="^.*\.(jpg|css|js|gif|png|eot|ttf|woff)$" negate="true" />
LoïcR
  • 4,940
  • 1
  • 34
  • 50