Route Problem at Angular accessed directly

Asked

Viewed 187 times

0

I published the Angular project on a machine with IIS, but when I try to access the link with a route directly shows error 404, example "http://meusite.com/appiis/login" but access the url "http://meusite.com/appiis/" it loads normally, and if it is not logged in the system redirects correctly to login, I can navigate any route normally through the angular, but the problem only occurs when I go directly through the browser. Is there any configuration in IIS or Angular that allows you to access the routes directly from the browser?

1 answer

1


According to the documentation you have to rewrite a file.

Try to rewrite the web.config file

<system.webServer>
  <rewrite>
    <rules>
      <rule name="Angular Routes" 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>
</system.webServer>
  • I was able to make it work, thanks for the north, with the help of tutorial https://blogs.msdn.microsoft.com/premier_developer/2017/06/14/tips-for-running-an-angular-app-in-iis/ I was able to solve the problem

Browser other questions tagged

You are not signed in. Login or sign up in order to post.