【问题标题】:ReactJS hosting in a subfolder not working properlyReactJS 托管在子文件夹中无法正常工作
【发布时间】:2020-08-06 22:25:33
【问题描述】:

我正在尝试将我的 ReactJS 项目托管在我的网络主机上的子文件夹中。

我将我的项目(生产)放在一个名为“仪表板”的文件夹中。所以现在我可以通过 http://hostname/dashboard 访问网站了。

但是,它给了我以下错误,因为它仍然试图从主文件夹中获取 styles.css 和 bundle.js。

我能做些什么来解决它?

function MainContent() {
  return (
    <div className="container" style={{ marginTop: 20 }}>
      <Switch>
        <Route exact path="/" component={Landing} />
        <Route path="/login" component={Login} />
        <Route path="/logout" component={Logout} />
        <Route path="/signup" component={Signup} />
        <Route component={NoMatch} />
      </Switch>
    </div>
  );
}

【问题讨论】:

标签: reactjs url path router hostname


【解决方案1】:

这是可能的,但如果您使用 AWS,则必须为路由分配额外的服务器,这会增加更多成本。到处找了也没找到最优解。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-10
    • 2022-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-30
    相关资源
    最近更新 更多