mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 15:23:38 +01:00
Added COUNTRY_IP_HEADER environment variable. Closes #814.
This commit is contained in:
parent
0a8c06b1f8
commit
b1ced5f32c
@ -3,6 +3,7 @@ import { useSelector } from 'react-redux';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
|
import { useRouter } from 'next/router';
|
||||||
import Page from '../layout/Page';
|
import Page from '../layout/Page';
|
||||||
import PageHeader from '../layout/PageHeader';
|
import PageHeader from '../layout/PageHeader';
|
||||||
import useFetch from '../../hooks/useFetch';
|
import useFetch from '../../hooks/useFetch';
|
||||||
@ -16,6 +17,7 @@ import EmptyPlaceholder from '../common/EmptyPlaceholder';
|
|||||||
export default function TestConsole() {
|
export default function TestConsole() {
|
||||||
const user = useSelector(state => state.user);
|
const user = useSelector(state => state.user);
|
||||||
const [website, setWebsite] = useState();
|
const [website, setWebsite] = useState();
|
||||||
|
const { basePath } = useRouter();
|
||||||
const { data } = useFetch('/api/websites');
|
const { data } = useFetch('/api/websites');
|
||||||
|
|
||||||
if (!data || !user?.is_admin) {
|
if (!data || !user?.is_admin) {
|
||||||
@ -39,7 +41,7 @@ export default function TestConsole() {
|
|||||||
<Page>
|
<Page>
|
||||||
<Head>
|
<Head>
|
||||||
{typeof window !== 'undefined' && website && (
|
{typeof window !== 'undefined' && website && (
|
||||||
<script async defer data-website-id={website.website_uuid} src="/umami.js" />
|
<script async defer data-website-id={website.website_uuid} src={`${basePath}/umami.js`} />
|
||||||
)}
|
)}
|
||||||
</Head>
|
</Head>
|
||||||
<PageHeader>
|
<PageHeader>
|
||||||
|
@ -52,6 +52,11 @@ export function getDevice(screen, browser, os) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getCountry(req, ip) {
|
export async function getCountry(req, ip) {
|
||||||
|
// Custom header
|
||||||
|
if (req.headers[process.env.COUNTRY_IP_HEADER]) {
|
||||||
|
return req.headers[process.env.COUNTRY_IP_HEADER];
|
||||||
|
}
|
||||||
|
|
||||||
// Cloudflare
|
// Cloudflare
|
||||||
if (req.headers['cf-ipcountry']) {
|
if (req.headers['cf-ipcountry']) {
|
||||||
return req.headers['cf-ipcountry'];
|
return req.headers['cf-ipcountry'];
|
||||||
|
Loading…
Reference in New Issue
Block a user