I have a React App which proxies requests to Django, and Django has allauth installed to manage social app login. But my app is SPA which uses react-router, so when I have a link like /accounts/github/login
, it seems like it is only passed to router, not attempred to open correctly. How can I exempt some url mask from routing?
Asked
Active
Viewed 1,016 times
1
RomaValcer
- 2,328
- 3
- 15
- 28
-
Check this article to help you setup protected routes (routerv4) based on authentication: https://tylermcginnis.com/react-router-protected-routes-authentication/ – AndreasT Apr 21 '18 at 08:38
-
@AndreasT, this is about showing the link only to those who are authenticated, not about redirecting to another page from SPA – RomaValcer Apr 21 '18 at 09:00
-
Sorry, i didn't understand your problem correctly. Do you want to redirect to an external URL? – AndreasT Apr 21 '18 at 09:17
-
@AndreasT A URL on the same website, but not within SPA. – RomaValcer Apr 21 '18 at 09:18
1 Answers
1
To redirect a route (page-URL) of your SPA to another page-URL -out of your SPA- use this:
<Route path='/login' component={() => window.location =
'https://example.com/somethingOutOfSPA'}/>
*works with router v3,v4
AndreasT
- 776
- 5
- 12