[Vuejs]-404 response when deploy vuejs using "npm run build"

0👍

You need to redirect all routes in IIS to /. This is the nature of SPAs, that only a single html file index.html is ever served no matter the URL path.

You can add something like the below rewrite rule to a web.config file in your project’s root directory.

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Vue SPA" 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>

Leave a comment