部署到服务器

时间:2017-07-04 02:37:46

标签: reactjs react-router-v4

我正在使用react-router v4。你可以在这里看到我的网站shell。 http://responder.azurewebsites.net/

点击底部的其中一个标签,例如第3个标签,转到此处: http://responder.azurewebsites.net/profile

如果您尝试刷新此页面或直接点击它,则会显示404。

然而,在localhost上,这种情况不会发生,事情也很顺利。

无法想到为什么它在本地工作但在服务器上刷新失败。

方向会很棒!

这是我的路由器

 <div className="App">
        <Header />
        <Router>
          <div className="App-content">
            <Route path="/bank" component={BankPage} />
            <Route path="/active-chats" component={ActiveChatsPage} />
            <Route path="/profile" component={ProfilePage} />
            <NavBar />
          </div>
        </Router>
      </div>

1 个答案:

答案 0 :(得分:0)

您应该添加此链接的路线。例如:如果您在服务器端使用Express和nodejs,请添加此

express().get('*', function(req, res) {...})

如果您在服务器端使用Php laravel,请将此行添加到路由文件(web.php)

Route::get('/{any?}', 'KeywordController@index');