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