问题
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