mirror of
https://github.com/kremalicious/umami.git
synced 2025-01-02 02:03:10 +01:00
Add force SSL check.
This commit is contained in:
parent
fc22f5969c
commit
4cafa68e23
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;
|
||||
}
|
@ -4,9 +4,7 @@ const pkg = require('./package.json');
|
||||
module.exports = {
|
||||
env: {
|
||||
VERSION: pkg.version,
|
||||
},
|
||||
serverRuntimeConfig: {
|
||||
PROJECT_ROOT: __dirname,
|
||||
FORCE_SSL: !!process.env.FORCE_SSL,
|
||||
},
|
||||
webpack(config) {
|
||||
config.module.rules.push({
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "umami",
|
||||
"version": "0.75.0",
|
||||
"version": "0.76.0",
|
||||
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
||||
"author": "Mike Cao <mike@mikecao.com>",
|
||||
"license": "MIT",
|
||||
|
@ -3,6 +3,7 @@ import { IntlProvider } from 'react-intl';
|
||||
import { Provider } from 'react-redux';
|
||||
import { useStore } from 'redux/store';
|
||||
import useLocale from 'hooks/useLocale';
|
||||
import useForceSSL from 'hooks/useForceSSL';
|
||||
import { messages } from 'lib/lang';
|
||||
import 'styles/variables.css';
|
||||
import 'styles/bootstrap-grid.css';
|
||||
@ -21,6 +22,7 @@ const Intl = ({ children }) => {
|
||||
};
|
||||
|
||||
export default function App({ Component, pageProps }) {
|
||||
useForceSSL(process.env.FORCE_SSL);
|
||||
const store = useStore();
|
||||
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user