Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.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 如何在react路由器中使用回调uri处理身份验证_Reactjs_Server_Oauth_Routes_React Router - Fatal编程技术网

Reactjs 如何在react路由器中使用回调uri处理身份验证

Reactjs 如何在react路由器中使用回调uri处理身份验证,reactjs,server,oauth,routes,react-router,Reactjs,Server,Oauth,Routes,React Router,我创建了第一个使用spotify api显示数据的react应用程序,但在部署到netlify或任何服务器时遇到了问题 Te身份验证流: 1.用户单击我的应用程序上的按钮,将其重定向到spotify/auth 2.Spotify auth check permissions和prompt login按钮,当成功将其用户重定向到我的应用程序的url,并在末尾使用/localhost 3.我使用react路由器和交换机组件来处理该/回调路由,并保存令牌和所有东西 在本地主机上工作正常,但在live

我创建了第一个使用spotify api显示数据的react应用程序,但在部署到netlify或任何服务器时遇到了问题 Te身份验证流: 1.用户单击我的应用程序上的按钮,将其重定向到spotify/auth 2.Spotify auth check permissions和prompt login按钮,当成功将其用户重定向到我的应用程序的url,并在末尾使用/localhost 3.我使用react路由器和交换机组件来处理该/回调路由,并保存令牌和所有东西 在本地主机上工作正常,但在live server或netlify上,当spotify将用户发送到/回调时会出现错误

这是我的反应路线设置

它说“无法获取/回调”

我真的搞不懂为什么会这样

 <Router>
    <Provider store={store}
        <Switch>
          <Route exact path="/" component={LoginView} />
          <Route exact path="/callback" component={CallBack} />
          <PrivateRoute path="/app">
            <AppView />
          </PrivateRoute>
        </Switch>
    </Provider>
  </Router>
  handleLogin = () => {
// redirect user to spotify to authenticate them
const params = queryString.stringify({
  client_id: "client_id,
  response_type: "token",
  redirect_uri: `${window.location.origin}/callback`,
  scope: "user-top-read playlist-modify-public playlist-modify-private",
});
window.location = `https://accounts.spotify.com/authorize?${params}`;