Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在启用SSL的情况下刷新URL时应对路由器问题_Javascript_Reactjs_Ssl_Nginx_React Router - Fatal编程技术网

Javascript 在启用SSL的情况下刷新URL时应对路由器问题

Javascript 在启用SSL的情况下刷新URL时应对路由器问题,javascript,reactjs,ssl,nginx,react-router,Javascript,Reactjs,Ssl,Nginx,React Router,目前,我在使用react router的BrowserHistory和nginx代理转发请求时遇到问题。我读了以下答案: 我正在寻找的解决方案似乎是一个包罗万象的解决方案,/*将所有传入请求转发到index.html 如果URL有一级深度,即/about,则此功能可以正常工作。但是,如果在子路由上尝试刷新页面,/some/other/url,页面将完全中断 以下是我当前的nginx配置(注意http->https的永久重定向): 在location/块中,您会注意到其他一些try\u文件语句,

目前,我在使用react router的BrowserHistory和nginx代理转发请求时遇到问题。我读了以下答案:

我正在寻找的解决方案似乎是一个包罗万象的解决方案,
/*
将所有传入请求转发到
index.html

如果URL有一级深度,即
/about
,则此功能可以正常工作。但是,如果在子路由上尝试刷新页面,
/some/other/url
,页面将完全中断

以下是我当前的nginx配置(注意http->https的永久重定向):

location/
块中,您会注意到其他一些
try\u文件
语句,这些语句是我试图使用的,但没有用

下面是
react路由器的逻辑:

<Route path="/user" component={ConnectedUserPage} />
      <Route path="/user/preview/:locationId" component={ConnectedUserPage} />
      <Route
        path="/user/preview/:locationId/menu"
        component={ConnectedUserPage}
        fullMenuVisible={true}
      />
      <Route
        path="/user/preview/:locationId/menu/:sectionName/:someId"
        component={ConnectedUserPage}
        dishDetailsVisible={true}
      />

      {/* Restaurant Profile */}
      <Route
        path="/location-profile/:profileId"
        component={LocationProfile}
        activeTabIndex={0}
      />
      <Route
        path="/location-profile/:profileId/gallery"
        component={LocationProfile}
        activeTabIndex={0}
      />
      <Route
        path="/location-profile/:profileId/gallery/:imageId"
        component={LocationProfile}
        activeTabIndex={0}
      />
      <Route
        path="/location-profile/:profileId/details"
        component={LocationProfile}
        activeTabIndex={1}
      />
      <Route
        path="/location-profile/:profileId/menu"
        component={LocationProfile}
        activeTabIndex={2}
      />
      <Route
        path="/location-profile/:profileId/comments"
        component={LocationProfile}
        activeTabIndex={3}
      />
      <Route
        path="/location-profile/:profileId/stuff"
        component={LocationProfile}
        activeTabIndex={4}
      />
      <Route
        path="/location-profile/:profileId/menu/:somethingName"
        component={LocationProfile}
        activeTabIndex={2}
      />
      <Route
        path="/location-profile/:profileId/menu/:somethingName/:someItemId"
        component={LocationProfile}
        activeTabIndex={2}
      />
      .
      .
      .
      .

{/*餐厅简介*/}
.
.
.
.

任何帮助或指导都将不胜感激

我遇到了类似于您的问题,我的团队花了很多时间研究nginx和react路由器,这与您的设置非常相似

我也有以下错误:

未捕获的语法错误:意外标记<错误

最后我找到了一个解决方案,thas实际上在我的index.html服务器文件中

我正在为我的包使用相对路径

<link href="styles.css" rel="stylesheet" />    
<script src="bundle.js"></script>
这就解决了这个问题。希望这对你有帮助

<link href="styles.css" rel="stylesheet" />    
<script src="bundle.js"></script>
<link href="/styles.css" rel="stylesheet" />
<script src="/bundle.js"></script>