How to remove accesstoken from the URL

你说的曾经没有我的故事 提交于 2021-01-07 06:57:53

问题


Right now I am getting my accesstoken from the url. I am using a GET request in the backend, which is passing the accesstoken to the URL. They key problem is, after I logged in successfully the accesstoken stays in the URL. I don't know how to get rid of that.

function App() {
  // ( getSpotifyTokenFromUrl() ) That function is getting me the token from the url
  const params = getSpotifyTokenFromUrl();
  const token = params.access_token;

  return (
    <Router>
      <div className="app">
        {token ? 
          <Route path="hompage">
            <Homepage spotify={spotify}/>
          </Route>
        : <Home />}
      </div>
    </Router>
  )

I also tried to do that in the index.js file

ReactDOM.render(
  <Router>
    <App>
      <Route exact path="/hompage" component={Homepage} />
    </App>
  </Router>,
  document.getElementById('root'));

This is a small part of my backend code, which is passing the token to the browser. Maybe I have to redirect again, but how?

res.redirect('http://localhost:3000/#' +
  querystring.stringify({
    access_token: access_token,
    refresh_token: refresh_token
  }));

来源:https://stackoverflow.com/questions/65432084/how-to-remove-accesstoken-from-the-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!