Skip to content

Commit 0a3b269

Browse files
committed
Setting Up a Reverse Proxy
1 parent 4451770 commit 0a3b269

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

next.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@ import "./src/env.js";
88
const config = {
99
eslint: { ignoreDuringBuilds: true },
1010
typescript: { ignoreBuildErrors: true },
11+
12+
async rewrites() {
13+
return [
14+
{
15+
source: "/relay-BxMI/static/:path*",
16+
destination: "https://us-assets.i.posthog.com/static/:path*",
17+
},
18+
{
19+
source: "/relay-BxMI/:path*",
20+
destination: "https://us.i.posthog.com/:path*",
21+
},
22+
{
23+
source: "/relay-BxMI/flags",
24+
destination: "https://us.i.posthog.com/flags",
25+
},
26+
];
27+
},
28+
skipTrailingSlashRedirect: true, // This is required to support PostHog trailing slash API requests
1129
};
1230

1331
export default config;

src/app/_providers/posthog-provider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import { env } from "~/env";
99
export function PostHogProvider({ children }: { children: React.ReactNode }) {
1010
useEffect(() => {
1111
posthog.init(env.NEXT_PUBLIC_POSTHOG_KEY, {
12-
api_host: env.NEXT_PUBLIC_POSTHOG_HOST,
12+
api_host: "/relay-BxMI",
13+
ui_host: env.NEXT_PUBLIC_POSTHOG_HOST,
1314
person_profiles: "identified_only", // or 'always' to create profiles for anonymous users as well
1415
defaults: "2025-05-24",
1516
});

0 commit comments

Comments
 (0)