Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/sim/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ API_ENCRYPTION_KEY=your_api_encryption_key # Use `openssl rand -hex 32` to gener
# Admin API (Optional - for self-hosted GitOps)
# ADMIN_API_KEY= # Use `openssl rand -hex 32` to generate. Enables admin API for workflow export/import.
# Usage: curl -H "x-admin-key: your_key" https://your-instance/api/v1/admin/workspaces

# Product Analytics - PostHog (Optional)
# NEXT_PUBLIC_POSTHOG_KEY=phc_... # Your PostHog project API key (from posthog.com or self-hosted)
# NEXT_PUBLIC_POSTHOG_ENABLED=true # Set to true to enable analytics. Omit or set to false to disable entirely.
# When disabled: server SDK never initializes, client SDK never loads.
8 changes: 8 additions & 0 deletions apps/sim/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,14 @@ const nextConfig: NextConfig = {
source: '/r/:shortCode',
destination: 'https://go.trybeluga.ai/:shortCode',
},
{
source: '/ingest/static/:path*',
destination: 'https://us-assets.i.posthog.com/static/:path*',
},
{
source: '/ingest/:path*',
destination: 'https://us.i.posthog.com/:path*',
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New rewrite rules are dead code due to existing route

Low Severity

The new /ingest rewrite rules will never be reached because an existing App Router route handler at app/ingest/[[...path]]/route.ts already handles all /ingest/* requests. Next.js evaluates filesystem routes (including API route handlers) before flat-array rewrites, so the optional catch-all route always takes precedence. These rewrites are effectively dead code and duplicate the proxy logic already implemented in the route handler.

Fix in Cursor Fix in Web

Comment on lines +421 to +427
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Rewrites conflict with (and are shadowed by) the existing route handler

PR #3187 (c471627ce) explicitly replaced these exact rewrites with app/ingest/[[...path]]/route.ts specifically for "reliable body streaming." That route handler already proxies all /ingest/* requests to us.i.posthog.com / us-assets.i.posthog.com, and does so with careful header handling (strips cookie, connection headers; sets Host; removes content-encoding on the response).

When rewrites() returns a plain array, Next.js treats them as afterFiles rewrites — meaning they only apply when no matching filesystem route exists. Since app/ingest/[[...path]]/route.ts is a valid App Router Route Handler for exactly these paths, Next.js will route traffic through the handler first, and these two rewrites will never execute.

In short, the new rewrites are dead code. If they were ever made to execute (e.g., if the route handler is later removed or if a future Next.js version changes precedence), they would silently regress the intentional improvements from #3187: request bodies may not stream reliably, and auth/session cookies would be forwarded to PostHog rather than stripped.

Consider removing these two rewrite entries to avoid confusion and keep the proxy logic consolidated in the route handler.

]
},
}
Expand Down
Loading