Skip to content

Commit

Permalink
Fix external redirects on named routes
Browse files Browse the repository at this point in the history
- Assign `window.location.href` since React Router's `<Navigate>` is not
  designed to work with external links
  • Loading branch information
taesungh committed Jan 3, 2024
1 parent b6c76e7 commit f02d11a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,26 @@ function App() {
{/* Redirects */}
<Route
path="discord"
element={<Navigate to="//discord.com/invite/MBVrKe9" />}
element={<Redirect to="https://discord.com/invite/MBVrKe9" />}
/>

{/* Leaving this redirect here since that link is posted on our insta */}
<Route path="impact22" element={<Navigate to="/designathon/22" />} />
<Route path="impact22" element={<Redirect to="/designathon/22" />} />
<Route
path="ptsignup"
element={<Navigate to={PROJECT_TEAMS_GOOGLE_FORM} />}
element={<Redirect to={PROJECT_TEAMS_GOOGLE_FORM} />}
/>
<Route
path="ptsignups"
element={<Navigate to={PROJECT_TEAMS_GOOGLE_FORM} />}
element={<Navigate to="/ptsignup" replace={true} />}
/>
{/* <Route
path='buy'
element={<Navigate to='//forms.gle/RVoUbLPQnHYzeWMA6' />}
element={<Redirect to='//forms.gle/RVoUbLPQnHYzeWMA6' />}
/> */}
{/* <Route
path='apply'
element={<Navigate to='//forms.gle/UXpfUfANHZ9m6fR47' />}
element={<Redirect to='//forms.gle/UXpfUfANHZ9m6fR47' />}
/> */}

<Route path="*" element={<NotFound />} />
Expand All @@ -97,4 +97,8 @@ function App() {
);
}

function Redirect({ to }) {
window.location.href = to;
}

export default App;

0 comments on commit f02d11a

Please sign in to comment.