Updated next config.

This commit is contained in:
Mike Cao 2020-09-26 20:46:20 -07:00
parent ad95da63b7
commit d1765f746b
3 changed files with 10 additions and 2 deletions

View file

@ -3,6 +3,9 @@ import requestIp from 'request-ip';
import { browserName, detectOS } from 'detect-browser';
import isLocalhost from 'is-localhost-ip';
import maxmind from 'maxmind';
import getConfig from 'next/config';
const { serverRuntimeConfig } = getConfig();
import {
DESKTOP_OS,
MOBILE_OS,
@ -60,7 +63,9 @@ export async function getCountry(req, ip) {
}
// Database lookup
const lookup = await maxmind.open(path.resolve(__dirname, '../geo/GeoLite2-Country.mmdb'));
const lookup = await maxmind.open(
path.resolve(serverRuntimeConfig.PROJECT_ROOT, '../geo/GeoLite2-Country.mmdb'),
);
const result = lookup.get(ip);