SOLVED

React routing on Edge

%3CLINGO-SUB%20id%3D%22lingo-sub-1451990%22%20slang%3D%22en-US%22%3EReact%20routing%20on%20Edge%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1451990%22%20slang%3D%22en-US%22%3E%3CP%3EI%20use%20HashRouter%20in%20my%20React%20app%20(%20hosted%20on%20IIS).%20Noticed%20that%20Edge%20browser%20somehow%20loses%20the%20hash%20path%20(%23%2Frest%20of%20path)%20when%20it%20returns%20from%20the%20server%20after%20authentication.%20So%20user%20ends%20up%20on%20the%20main%20page.%20However%2C%20it%20works%20as%20expected(retains%20hash%20path)%20on%20the%20consecutive%20try%2C%20or%20if%20the%20browser%20has%20the%20application%20open%20on%20another%20window%20or%20tab.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENot%20sure%20where%20to%20look%20for%20answers%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1459477%22%20slang%3D%22en-US%22%3ERe%3A%20React%20routing%20on%20Edge%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1459477%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F694284%22%20target%3D%22_blank%22%3E%40vindiW%3C%2FA%3E%26nbsp%3BThanks%20for%20reaching%20out.%20It%20sounds%20like%20this%20might%20be%20related%20to%20a%20known%20issue%20in%20Chromium%20code%2C%20which%20there%20are%20a%20number%20of%20open%20bugs%20for%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CA%20tabindex%3D%22-1%22%20title%3D%22https%3A%2F%2Fbugs.chromium.org%2Fp%2Fchromium%2Fissues%2Fdetail%3Fid%3D1055455%22%20href%3D%22https%3A%2F%2Fbugs.chromium.org%2Fp%2Fchromium%2Fissues%2Fdetail%3Fid%3D1055455%22%20target%3D%22_blank%22%20rel%3D%22noreferrer%20noopener%20nofollow%22%3Ehttps%3A%2F%2Fbugs.chromium.org%2Fp%2Fchromium%2Fissues%2Fdetail%3Fid%3D1055455%3C%2FA%3E%2C%20%3CA%20tabindex%3D%22-1%22%20title%3D%22https%3A%2F%2Fbugs.chromium.org%2Fp%2Fchromium%2Fissues%2Fdetail%3Fid%3D1035537%22%20href%3D%22https%3A%2F%2Fbugs.chromium.org%2Fp%2Fchromium%2Fissues%2Fdetail%3Fid%3D1035537%22%20target%3D%22_blank%22%20rel%3D%22noreferrer%20noopener%20nofollow%22%3Ehttps%3A%2F%2Fbugs.chromium.org%2Fp%2Fchromium%2Fissues%2Fdetail%3Fid%3D1035537%3C%2FA%3E%2C%20%3CA%20tabindex%3D%22-1%22%20title%3D%22https%3A%2F%2Fbugs.chromium.org%2Fp%2Fchromium%2Fissues%2Fdetail%3Fid%3D1027954%22%20href%3D%22https%3A%2F%2Fbugs.chromium.org%2Fp%2Fchromium%2Fissues%2Fdetail%3Fid%3D1027954%22%20target%3D%22_blank%22%20rel%3D%22noreferrer%20noopener%20nofollow%22%3Ehttps%3A%2F%2Fbugs.chromium.org%2Fp%2Fchromium%2Fissues%2Fdetail%3Fid%3D1027954%3C%2FA%3E%2C%20%3CA%20tabindex%3D%22-1%22%20title%3D%22https%3A%2F%2Fbugs.chromium.org%2Fp%2Fchromium%2Fissues%2Fdetail%3Fid%3D889833%22%20href%3D%22https%3A%2F%2Fbugs.chromium.org%2Fp%2Fchromium%2Fissues%2Fdetail%3Fid%3D889833%22%20target%3D%22_blank%22%20rel%3D%22noreferrer%20noopener%20nofollow%22%3Ehttps%3A%2F%2Fbugs.chromium.org%2Fp%2Fchromium%2Fissues%2Fdetail%3Fid%3D889833%3C%2FA%3E%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3EBut%20if%20you%20haven't%20yet%2C%20can%20you%20please%20submit%20feedback%20and%20diagnostic%20data%20through%20the%20browser%3F%20(Shift%2BAlt%2BI).%20In%20the%20meantime%2C%20I'll%20loop%20in%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F317619%22%20target%3D%22_blank%22%3E%40ericlaw%3C%2FA%3E%26nbsp%3Bto%20see%20if%20he%20has%20any%20additional%20insights.%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3E%3CI%3EFawkes%20(they%2Fthem)%3CBR%20%2F%3E%3CBR%20%2F%3EProject%20%26amp%3B%20Community%20Manager%20-%20Microsoft%20Edge%3CI%3E%3C%2FI%3E%3C%2FI%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1459535%22%20slang%3D%22en-US%22%3ERe%3A%20React%20routing%20on%20Edge%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1459535%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F317619%22%20target%3D%22_blank%22%3E%40ericlaw%3C%2FA%3E%26nbsp%3BYes.%20You%20are%20exactly%20right%20about%2C%26nbsp%3B%3CSPAN%3Ethat%20URL%20fragment%20being%20preserved.%20But%20it%20seems%20the%20the%20hash%20fragment%20is%20not%20preserved%20or%20ignored%20during%20the%20redirect(%20after%20SSO)%20as%20the%20auth%20token%20is%20attached%20to%20the%20hash%20of%20the%20URL(this%20is%20what%20I%20read).%20So%20I%20found%20a%20workaround%20to%20preserve%20the%20hash%20fragment%20(append%20as%20a%20query%20param)%20on%20client%20side%20and%20reattach%20it%20to%20the%20returning%20URL.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThanks%20for%20your%20time%20and%20information%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1459540%22%20slang%3D%22en-US%22%3ERe%3A%20React%20routing%20on%20Edge%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1459540%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F484598%22%20target%3D%22_blank%22%3E%40fawkes%3C%2FA%3E%26nbsp%3BThanks%20for%20getting%20back.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20found%20the%20issue%20and%20it%20is%20related%20to%20the%20SSO%20and%20seems%20losing%20the%20hash%20fragment%20of%20the%20URL%20is%20common%20issue.%20the%20browser%20however%20preserve%20it%20along%20with%20all%20other%20URL%20fragments%2C%20but%20the%20server%20that%20handles%20authentication%20seems%20to%20be%20removing%20it.%20I%20found%20a%20workaround%20to%20fix%20this%20temporarily.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThat%20list%20is%20definitely%20worth%20saving%20though%2C%20for%20future%20references%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%20for%20your%20time%2C%20appreciate%20it%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1459507%22%20slang%3D%22en-US%22%3ERe%3A%20React%20routing%20on%20Edge%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1459507%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F484598%22%20target%3D%22_blank%22%3E%40fawkes%3C%2FA%3E%26nbsp%3B-%20That's%20an%20impressive%20list%20of%20URL%20Fragment%20related%20issues%2C%20but%20none%20of%20them%20are%20likely%20relevant%20here.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F694284%22%20target%3D%22_blank%22%3E%40vindiW%3C%2FA%3E%26nbsp%3B-%20You%20can%20watch%20your%20network%20traffic%20to%20see%20what's%20going%20on%2C%20but%20the%26nbsp%3B%3CSTRONG%3Emost%20likely%26nbsp%3B%3C%2FSTRONG%3Eexplanation%20here%20is%20that%20this%20is%20related%20to%20behavior%20of%20your%20your%20authentication%20provider.%20In%20particular%2C%20if%20you%20have%20a%20URL%20fragment%20that%20goes%20through%20a%20set%20of%20HTTP%2F3xx%20redirects%2C%20that%20URL%20fragment%20is%20meant%20to%20be%20preserved%2C%20and%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Farchive%2Fblogs%2Fieinternals%2Furl-fragments-and-redirects%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Eit%20is%2C%20within%20modern%20browsers%3C%2FA%3E.%26nbsp%3B%3CSTRONG%3EHowever%3C%2FSTRONG%3E%2C%20if%20the%20server%20returns%20a%20HTTP%2F200%20response%20(e.g.%20because%20it%20wants%20you%20to%20enter%20your%20credentials)%2C%20then%20when%20it%20redirects%20back%20to%20the%20relying%20party%20website%2C%20that%20URL%20fragment%20is%20not%20automatically%20carried%20through.%3CBR%20%2F%3E%3CBR%20%2F%3EIf%20you'd%20like%2C%20I%20can%20take%20a%20look%26nbsp%3B%3CSTRONG%3E%5Bpersonal%20information%20removed%20by%20Mod%5D%26nbsp%3B%3C%2FSTRONG%3Eat%20a%20NetLog%20for%20you%20(%3CA%20href%3D%22https%3A%2F%2Ftextslashplain.com%2F2020%2F01%2F17%2Fcapture-network-logs-from-edge-and-chrome%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Ftextslashplain.com%2F2020%2F01%2F17%2Fcapture-network-logs-from-edge-and-chrome%2F%3C%2FA%3E)%20to%20confirm.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

I use HashRouter in my React app ( hosted on IIS). Noticed that Edge browser somehow loses the hash path (#/rest of path) when it returns from the server after authentication. So user ends up on the main page. However, it works as expected(retains hash path) on the consecutive try, or if the browser has the application open on another window or tab. 

 

Not sure where to look for answers

4 Replies

@vindiW Thanks for reaching out. It sounds like this might be related to a known issue in Chromium code, which there are a number of open bugs for:

 

 
But if you haven't yet, can you please submit feedback and diagnostic data through the browser? (Shift+Alt+I). In the meantime, I'll loop in @ericlaw to see if he has any additional insights.
 
Fawkes (they/them)
Project & Community Manager - Microsoft Edge
best response
Solution

@Deleted - That's an impressive list of URL Fragment related issues, but none of them are likely relevant here.

@vindiW - You can watch your network traffic to see what's going on, but the most likely explanation here is that this is related to behavior of your your authentication provider. In particular, if you have a URL fragment that goes through a set of HTTP/3xx redirects, that URL fragment is meant to be preserved, and it is, within modern browsersHowever, if the server returns a HTTP/200 response (e.g. because it wants you to enter your credentials), then when it redirects back to the relying party website, that URL fragment is not automatically carried through.

If you'd like, I can take a look [personal information removed by Mod] at a NetLog for you (https://textslashplain.com/2020/01/17/capture-network-logs-from-edge-and-chrome/) to confirm.

@ericlaw Yes. You are exactly right about, that URL fragment being preserved. But it seems the the hash fragment is not preserved or ignored during the redirect( after SSO) as the auth token is attached to the hash of the URL(this is what I read). So I found a workaround to preserve the hash fragment (append as a query param) on client side and reattach it to the returning URL. 

 

Thanks for your time and information

@Deleted Thanks for getting back. 

I found the issue and it is related to the SSO and seems losing the hash fragment of the URL is common issue. the browser however preserve it along with all other URL fragments, but the server that handles authentication seems to be removing it. I found a workaround to fix this temporarily. 

 

That list is definitely worth saving though, for future references

 

Thanks for your time, appreciate it