Merge pull request #5 from auravoid/main

Fix error when PLAUSIBLE_HOST is missing
This commit is contained in:
Erisa A 2022-12-24 04:02:21 +00:00 committed by GitHub
commit 91f42a9eab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -62,7 +62,7 @@ async function handleRequest(event) {
} else { } else {
// PLAUSIBLE_HOST should be the full URL to your Plausible Analytics instance // PLAUSIBLE_HOST should be the full URL to your Plausible Analytics instance
// e.g. https://plausible.io/ // e.g. https://plausible.io/
if (PLAUSIBLE_HOST !== undefined) { if (typeof PLAUSIBLE_HOST !== 'undefined') {
const url = PLAUSIBLE_HOST + 'api/event' const url = PLAUSIBLE_HOST + 'api/event'
const headers = new Headers() const headers = new Headers()
headers.append('User-Agent', request.headers.get('User-Agent')) headers.append('User-Agent', request.headers.get('User-Agent'))