From d3f5f42d02645da9cca8d81cf295b0409f3e4be8 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Tue, 23 Aug 2022 11:52:55 -0700 Subject: [PATCH] Fix geo lookup for Netlify. --- lib/request.js | 3 +-- netlify.toml | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/request.js b/lib/request.js index 210921b986..cb9abc7b57 100644 --- a/lib/request.js +++ b/lib/request.js @@ -1,4 +1,3 @@ -import path from 'path'; import requestIp from 'request-ip'; import { browserName, detectOS } from 'detect-browser'; import isLocalhost from 'is-localhost-ip'; @@ -68,7 +67,7 @@ export async function getCountry(req, ip) { // Database lookup if (!lookup) { - lookup = await maxmind.open(path.resolve('node_modules/.geo/GeoLite2-Country.mmdb')); + lookup = await maxmind.open('./node_modules/.geo/GeoLite2-Country.mmdb'); } const result = lookup.get(ip); diff --git a/netlify.toml b/netlify.toml index 51e90db9f4..0d8c6fc18f 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,2 +1,2 @@ [functions] -included_files = ["node_modules/.geo/*.mmdb"] +included_files = ["node_modules/.geo/**"]