【发布时间】:2018-10-15 10:26:06
【问题描述】:
以下组件是从我的 React 应用程序的 App.js 加载的。
const Main = () => (
<BrowserRouter>
<Switch>
<Route exact path="/:userid" component={Banks} />
</Switch>
</BrowserRouter>
);
当应用程序使用本地开发服务器运行时,我可以从以下 url 获取用户 ID:
但是,当我构建应用程序并将其托管在 IIS 中时,我无法获取用户 ID。
https://localhost/Bank/100 --> 将 HTTP 更新为 HTTPS
路由无法识别。我使用了 URL Rewrite 但 userid 的值仍然没有进来。
<system.webServer>
<rewrite>
<rules>
<rule name="Routing" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
index.html:
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="./manifest.json"><link rel="shortcut icon" href="./favicon.ico"><title>Bank App</title><link href="./static/css/main.b730bb13.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script type="text/javascript" src="./static/js/main.2564873f.js"></script></body></html>
【问题讨论】:
-
将您的构建
index.htmlunminified 添加到此问题 -
你的 html 中没有基本标签