mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-24 02:57:53 +01:00
15 lines
372 B
JavaScript
15 lines
372 B
JavaScript
import { useEffect } from 'react';
|
|
import { useRouter } from 'next/router';
|
|
|
|
export default function useForceSSL(enabled) {
|
|
const router = useRouter();
|
|
|
|
useEffect(() => {
|
|
if (enabled && typeof window !== 'undefined' && /^http:\/\//.test(location.href)) {
|
|
router.push(location.href.replace(/^http:\/\//, 'https://'));
|
|
}
|
|
}, [enabled]);
|
|
|
|
return null;
|
|
}
|