Skip to content

Commit aca2ab8

Browse files
refactor(msw): align setup with next-msw-integration pattern
- Remove instrumentation.ts (Next.js hook approach) - Move server-side MSW init to layout.tsx using require() - Clean up debug console.log statements from: - lib/supabase/server.ts - proxy.ts - app/auth/callback/route.ts - lib/actions/board.ts This follows the simpler pattern from laststance/next-msw-integration without requiring Next.js experimental features.
1 parent e5ad453 commit aca2ab8

File tree

6 files changed

+8
-46
lines changed

6 files changed

+8
-46
lines changed

app/auth/callback/route.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export async function GET(request: Request) {
6464
maxAge: 60 * 60 * 24 * 7, // 7 days (adjust to match GitHub token expiration)
6565
path: '/',
6666
})
67-
console.log(`GitHub provider_token saved to cookie: ${cookieName}`)
6867
} else {
6968
console.warn(
7069
'No provider_token in session - GitHub API access may be limited',

app/layout.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,17 @@ import { Toaster } from 'sonner'
3030
import { CommandPalette } from '@/components/CommandPalette/CommandPalette'
3131
import { ShortcutsHelp } from '@/components/ShortcutsHelp'
3232
import { Providers } from '@/lib/redux/providers'
33+
import { isMSWEnabled } from '@/lib/utils/isMSWEnabled'
3334

3435
import { MSWProvider } from './msw-provider'
3536

36-
// NOTE: Server-side MSW is initialized via instrumentation.ts (Next.js hook)
37-
// This ensures MSW starts BEFORE any route handlers run.
37+
// Server-side MSW initialization (runs at module load time)
38+
// Uses require() to avoid bundling issues with Next.js SSR
39+
if (process.env.NEXT_RUNTIME === 'nodejs' && isMSWEnabled()) {
40+
// eslint-disable-next-line @typescript-eslint/no-require-imports
41+
const { server } = require('../mocks/server')
42+
server.listen({ onUnhandledRequest: 'bypass' })
43+
}
3844

3945
export default function RootLayout({
4046
children,

instrumentation.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

lib/actions/board.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,5 @@ export async function createFirstBoardIfNeeded(
777777
// Non-critical - don't block
778778
}
779779

780-
console.log('Created first board for new user:', data.id)
781-
782780
return { id: data.id, name: data.name }
783781
}

lib/supabase/server.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@ export async function createClient() {
6767

6868
// In E2E test mode, wrap auth methods to return mock data
6969
const testMode = isE2ETestMode()
70-
console.log(
71-
'[createClient] APP_ENV:',
72-
process.env.APP_ENV,
73-
'NODE_ENV:',
74-
process.env.NODE_ENV,
75-
'isE2ETestMode:',
76-
testMode,
77-
)
7870
if (testMode) {
7971
// Use a Proxy to intercept auth methods while preserving all other client functionality
8072
const mockedAuth = {

proxy.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const isE2ETestMode = () =>
2424
export async function proxy(request: NextRequest) {
2525
// In E2E test mode, bypass authentication and allow all requests
2626
if (isE2ETestMode()) {
27-
console.log('[proxy] E2E test mode - bypassing auth check')
2827
return NextResponse.next({
2928
request: {
3029
headers: request.headers,

0 commit comments

Comments
 (0)