From bb04015b46065cf3fae9c5e81f6d122bf90ffae4 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Sat, 18 Jul 2020 03:44:54 -0700 Subject: [PATCH] Send raw JSON. --- components/layout.js | 2 +- lib/utils.js | 4 ++-- scripts/umami/index.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/layout.js b/components/layout.js index 9024686b..c3880bd3 100644 --- a/components/layout.js +++ b/components/layout.js @@ -18,7 +18,7 @@ export default function Layout({ title, children }) { async defer data-website-id="865234ad-6a92-11e7-8846-b05adad3f099" - src="http://umami.is/umami.js" + src="/umami.js" /> )} diff --git a/lib/utils.js b/lib/utils.js index 79879602..18b94fa1 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -62,7 +62,7 @@ export async function getCountry(req, ip) { export async function parseSessionRequest(req) { const ip = getIpAddress(req); - const { website_id, screen, language } = JSON.parse(req.body); + const { website_id, screen, language } = req.body; const { userAgent, browser, os } = getDevice(req); const country = await getCountry(req, ip); const session_id = hash(`${website_id}${ip}${userAgent}${os}`); @@ -79,7 +79,7 @@ export async function parseSessionRequest(req) { } export function parseCollectRequest(req) { - const { type, payload } = JSON.parse(req.body); + const { type, payload } = req.body; if (payload.session) { const { diff --git a/scripts/umami/index.js b/scripts/umami/index.js index e48a969e..f86896da 100644 --- a/scripts/umami/index.js +++ b/scripts/umami/index.js @@ -18,7 +18,7 @@ function post(url, params) { headers: { 'Content-Type': 'application/json', }, - body: JSON.stringify(params), + body: params, }).then(res => res.json()); }