mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-07-25 12:01:04 +02:00
1.34.0 replaced the next.config `/api/* -> BACKEND_URL` rewrite with the Route Handler `api/v1/[...path]/route.ts`. Route Handlers proxy HTTP fine (so `/api/v1/*` still 200s) but cannot upgrade WebSocket connections. The removed *rewrite* used to carry the upgrade, so without it the signaling socket (`/api/v1/ws/signaling/...`) has no proxy path and every local web call dies before WebRTC negotiation — the symptom reported in #425. nginx would proxy the upgrade but only runs in the `remote` compose profile, so local OSS deployments have nothing to carry it. Re-add a `beforeFiles` rewrite scoped to `/api/v1/ws/:path*` so the upgrade is proxied to the backend *before* the `[...path]` Route Handler can swallow it. HTTP `/api/v1/*` is untouched and still flows through the Route Handler (auth/cookie handling intact). Verified on a 1.34.0-derived source build: signaling WS now reports `[accepted]` / `connection open` server-side and `WebSocket connected` + `ICE connection state: connected` client-side; WebRTC negotiates end-to-end. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
75 lines
2.7 KiB
TypeScript
75 lines
2.7 KiB
TypeScript
import { withSentryConfig } from "@sentry/nextjs";
|
|
import type { NextConfig } from "next";
|
|
|
|
const nextConfig: NextConfig = {
|
|
/* config options here */
|
|
output: 'standalone',
|
|
experimental: {
|
|
serverSourceMaps: true,
|
|
},
|
|
async rewrites() {
|
|
return {
|
|
// beforeFiles runs before Next.js route handlers, so the WebSocket
|
|
// signaling path is proxied straight to the backend instead of being
|
|
// swallowed by api/v1/[...path]/route.ts — a Route Handler that proxies
|
|
// HTTP fine but CANNOT upgrade WebSocket connections. The pre-1.34.0
|
|
// /api proxy *rewrite* used to carry this upgrade; removing it broke all
|
|
// local web calls (dograh #425). Scoped to /ws/ so HTTP /api/v1 still
|
|
// flows through the route handler (auth/cookie handling intact).
|
|
beforeFiles: [
|
|
{
|
|
source: "/api/v1/ws/:path*",
|
|
destination: `${process.env.BACKEND_URL || 'http://localhost:8000'}/api/v1/ws/:path*`,
|
|
},
|
|
],
|
|
afterFiles: [
|
|
{
|
|
source: "/ingest/static/:path*",
|
|
destination: "https://us-assets.i.posthog.com/static/:path*",
|
|
},
|
|
{
|
|
source: "/ingest/:path*",
|
|
destination: "https://us.i.posthog.com/:path*",
|
|
},
|
|
{
|
|
source: "/ingest/decide",
|
|
destination: "https://us.i.posthog.com/decide",
|
|
},
|
|
],
|
|
};
|
|
},
|
|
// This is required to support PostHog trailing slash API requests
|
|
skipTrailingSlashRedirect: true,
|
|
};
|
|
|
|
export default withSentryConfig(nextConfig, {
|
|
// For all available options, see:
|
|
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
|
|
|
|
org: "dograh",
|
|
project: "javascript-nextjs",
|
|
|
|
// Only print logs for uploading source maps in CI
|
|
silent: !process.env.CI,
|
|
|
|
// For all available options, see:
|
|
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
|
|
|
|
// Upload a larger set of source maps for prettier stack traces (increases build time)
|
|
widenClientFileUpload: true,
|
|
|
|
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
|
|
// This can increase your server load as well as your hosting bill.
|
|
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
|
|
// side errors will fail.
|
|
tunnelRoute: "/monitoring",
|
|
|
|
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
|
disableLogger: true,
|
|
|
|
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
|
|
// See the following for more information:
|
|
// https://docs.sentry.io/product/crons/
|
|
// https://vercel.com/docs/cron-jobs
|
|
automaticVercelMonitors: true,
|
|
});
|