Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.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
Reactjs 反应路由器-尝试在重定向时加载=_Reactjs_React Router - Fatal编程技术网

Reactjs 反应路由器-尝试在重定向时加载=

Reactjs 反应路由器-尝试在重定向时加载=,reactjs,react-router,Reactjs,React Router,我有一个node.js应用程序,它在登录时重定向到。这是使用expressJS完成的,如下所示: res.redirect('http://localhost:8080/'); Chrome中的开发者工具显示它正在按预期重定向,因为它执行以下操作: Request URL: http://localhost:8080/ Request Method: GET Status Code: 304 Not Modified Remote Address: 127.0.0.1:8080 const r

我有一个node.js应用程序,它在登录时重定向到。这是使用expressJS完成的,如下所示:

res.redirect('http://localhost:8080/');

Chrome中的开发者工具显示它正在按预期重定向,因为它执行以下操作:

Request URL: http://localhost:8080/
Request Method: GET
Status Code: 304 Not Modified
Remote Address: 127.0.0.1:8080
const routes = <Route component={AppContainer}>
  <Route path="/" component={DashboardContainer} />
  <Route path="settings" component={SettingsContainer}>
    <Route path="projects" component={ProjectsContainer}>
      <Route path="new" component={NewProject} />
    </Route>
    <Route path="views" component={ViewsContainer}>
      <Route path="new" component={NewView} />
      <Route path=":id" component={EditView} />
    </Route>
    <Route path="themes" component={Themes} />
  </Route>
</Route>;
在localhost:8080上有一个react应用程序,它使用react路由器来处理路由。其配置如下所示:

Request URL: http://localhost:8080/
Request Method: GET
Status Code: 304 Not Modified
Remote Address: 127.0.0.1:8080
const routes = <Route component={AppContainer}>
  <Route path="/" component={DashboardContainer} />
  <Route path="settings" component={SettingsContainer}>
    <Route path="projects" component={ProjectsContainer}>
      <Route path="new" component={NewProject} />
    </Route>
    <Route path="views" component={ViewsContainer}>
      <Route path="new" component={NewView} />
      <Route path=":id" component={EditView} />
    </Route>
    <Route path="themes" component={Themes} />
  </Route>
</Route>;
const路由=
;
但由于某些原因,应用程序被重定向到
http://localhost:8080/#/_=_?_k=1yp57h
这会给出“警告:[react router]位置”/
“不匹配任何路由”

但是,如果我直接加载或在浏览器中加载(跳过重定向部分),它就会加载,并且应用程序工作正常


知道发生了什么吗?

解决了!node.js上的身份验证过程与Facebook集成。事实证明,在Facebook的回调URL中,它在URL的末尾返回一个#=,当我运行
res.redirect('http://localhost:8080/');它保留了散列(不认为浏览器应该这样工作)并重定向到
http://localhost:8080/#_=_

为了解决这个问题,我只是强制哈希为nothing:
res.redirect('http://localhost:8080/#');