I'm developing a custom SPFx web part for our Sharepoint Online intranet. A couple of our test users have reported loading the page containing the web part, the page is either reloaded and/or they're automatically being redirected to http://acme.sharepoint.com/default.aspx
. Since I can't reproduce the error, I can't be 100% sure it's my webpart that's causing the redirect, but as this page is the only one causing such a redirect I think it's fairly safe to assume it's my web part that's causing the redirect.
As I'm not able to reproduce it, it's hard debugging the issue. So I though I'd reach out to the SPO community for advice. Have other SPO devs experienced the same type of issue, and could shed some light as to what's causing this?
I've wrapped the entire business logic inside a try/catch in an attempt to try to prevent any errors to crash the web part, like this.
public async componentDidMount() {
try {
await this.loadStuff()
}
catch (error) {
this.setState({errorMessage: JSON.stringify(error)}); // Displays an error message to the user
I don't believe the this.setState
would cause the webpart to crash, so I don't believe it's this feature that's causing the page reload and/or automatic redirect.
Update #1: I looks like the redirect is caused by the login action performed by the webpart, in which the user is temporarily redirected to a spfx login page, and then back. Don't have the exact details at hand at the moment, but if this is the case I need to find a way to avoid this redirect. This may explain what's been experienced as a page reload, though I doesn't explain why users sometimes are redirected to http://acme.sharepoint.com/default.aspx
Update #2: Moving the discussion over to Spfx with PnP.js / Graph: How to prevent redirect to spfxsinglesignon.aspx