Skip to content

Commit

Permalink
Merge pull request #71 from AudiusProject/jowlee-https
Browse files Browse the repository at this point in the history
Route http to https
  • Loading branch information
jowlee authored and michellebrier committed Oct 9, 2023
1 parent d195238 commit fe89594
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/protocol-dashboard/src/hooks/useRerouteLegacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,25 @@ import { useLocation } from 'react-router-dom'
* NOTE: After switching to ipfs hosted, we can remove entirely
*/

const AUDIUS_URL = process.env.REACT_APP_AUDIUS_URL || ''

// -------------------------------- Hooks --------------------------------
export const useRerouteLegacy = () => {
const location = useLocation()
useEffect(() => {
if (
window.location.pathname !== '/' &&
!window.location.pathname.includes('/ipns')
!window.location.pathname.includes('/ipns') &&
!window.location.pathname.includes('/ipfs')
) {
window.history.replaceState({}, '', `/#${window.location.pathname}`)
} else if (
window.location.protocol === 'http:' &&
window.location.hostname !== 'localhost' &&
AUDIUS_URL.includes('https:')
) {
const updatedHref = window.location.href.replace('http:', 'https:')
window.location.replace(updatedHref)
}
}, [location])
}
Expand Down

0 comments on commit fe89594

Please sign in to comment.