Как узнать, почему приложение Angular, работающее на IIS, не позволяет «Открыть ссылку в новой вкладке» для маршрута / URL? - PullRequest
1 голос
/ 26 июня 2019

Это работает на сервере угловой разработки, но на IIS (10.0) я получаю

404 - Файл или каталог не найдены.Возможно, ресурс, который вы ищете, был удален, изменилось его имя или временно недоступен.

в Chrome.Когда я нажимаю на ссылку, она работает без проблем.На сервере угловой разработки я использую proxy.conf.json для включения API-вызовов.В IIS они определены следующим образом.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="ReverseProxyInboundRule3" stopProcessing="true">
                    <match url="(.*pn/api/.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="{C:1}://b-XXX:19100/{C:3}" logRewrittenUrl="true" />
                </rule>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*api/.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{CACHE_URL}" pattern="^(https?)://([^/]+).*(api/.*)" />
                    </conditions>
                    <action type="Rewrite" url="{C:1}://b-ZZZ:18221/{C:3}" logRewrittenUrl="true" />
                </rule>
            </rules>
        </rewrite>
        <staticContent>
            <mimeMap fileExtension=".cmap" mimeType="text/plain" />
            <mimeMap fileExtension=".pdm" mimeType="text/plain" />
            <mimeMap fileExtension=".pdt" mimeType="text/plain" />
        </staticContent>
    </system.webServer>
</configuration>

Мой index.html выглядит следующим образом:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>YYY App</title>
  <base href="/yyyapp/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="styles.0a90b702423cc0234e73.css"></head>
<body>
  <app-root>Loading...</app-root>
<script type="text/javascript" src="runtime.26209474bfa8dc87a77c.js"></script><script type="text/javascript" src="polyfills.a73720f7fce1093697ef.js"></script><script type="text/javascript" src="scripts.9142a59cca85c6bb7aa5.js"></script><script type="text/javascript" src="main.fc2905abff461388a63e.js"></script></body>
</html>

1 Ответ

1 голос
/ 26 июня 2019

Добавить web.config файл на сервер

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="AngularJS" 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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...