Skip to content

Commit 6257782

Browse files
committed
feat(server): add basePath option
1 parent 8d1eda5 commit 6257782

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/analytics/src/plugin/with-simple-analytics.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function buildClientHintHeaders(clientHints?: ClientHints) {
3030
interface WithSimpleAnalyticsOptions {
3131
hostname?: string;
3232
clientHints?: ClientHints;
33+
basePath?: boolean;
3334
}
3435

3536
export function withSimpleAnalytics(
@@ -48,17 +49,21 @@ export function withSimpleAnalytics(
4849
const nextAnalyticsConfig: NextConfig = {
4950
async rewrites() {
5051
const existingRewrites = await nextConfig.rewrites?.();
52+
const basePath = !nextConfig.basePath;
5153

5254
const rewrites = [
5355
{
56+
basePath,
5457
source: "/proxy.js",
5558
destination: `https://simpleanalyticsexternal.com/proxy.js?hostname=${hostname}&path=/simple`,
5659
},
5760
{
61+
basePath,
5862
source: "/auto-events.js",
5963
destination: "https://scripts.simpleanalyticscdn.com/auto-events.js",
6064
},
6165
{
66+
basePath,
6267
source: "/simple/:match*",
6368
destination: "https://queue.simpleanalyticscdn.com/:match*",
6469
},

0 commit comments

Comments
 (0)