我已经通过Spotify在我的项目上设置了授权,它在本地工作,并且在我的Heroku临时环境中工作,但不在我的Heroku生产环境中工作。它要么超时,要么留在空白页上。我曾经能够通过Facebook将其转到Spotify登录,但在提交时超时。不知道这可能是什么原因,想知道是不是因为应用程序中添加了自定义域。
onSuccess = (response, mutation) => {
this.setState({error: false, loading: true})
mutation({
variables: { accessToken: response.access_token}
})
.then((res) => {
this.setState({loading: false})
this.props.history.push(`/`)
window.location.reload();
})
.catch((error) => {
this.setState({loading: false})
this.setState({error: true, errorMsg: "Something went wrong, please try again"})
})
}
onFailure = (response) => {
this.setState({click: false, error: true, errorMsg: "Something went wrong, please try again"})
}
<SpotifyLogin
clientId={process.env.REACT_APP_SPOTIFY_ID}
onClick={() => this.setState({click: true})}
redirectUri={process.env.REACT_APP_SPOTIFY_URL || "http://localhost:3000/"}
onSuccess={(data) => this.onSuccess(data, mutation)}
onFailure={this.onFailure}
scope="user-read-private user-top-read user-read-email user-read-playback-state"
className="onboarding__spotify-cta"
/>

发布于 2020-06-17 21:39:46
如果问题不是在你的开发环境中,而是在你的prod中,那是因为你的重定向uri有问题,检查你的process.env.REACT_APP_SPOTIFY_URL是否正确
https://stackoverflow.com/questions/62421652
复制相似问题