commit
4047a7ec23
378 changed files with 29334 additions and 0 deletions
14
hooks/useForceSSL.js
Normal file
14
hooks/useForceSSL.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue