Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

fix(core): fix inspector cors conflicting with main cors#1325

Closed
NathanFlurry wants to merge 1 commit intomainfrom
10-01-fix_core_fix_inspector_cors_conflicting_with_main_cors
Closed

fix(core): fix inspector cors conflicting with main cors#1325
NathanFlurry wants to merge 1 commit intomainfrom
10-01-fix_core_fix_inspector_cors_conflicting_with_main_cors

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

No description provided.

@vercel
Copy link
Copy Markdown

vercel bot commented Oct 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
rivetkit-serverless Ready Ready Preview Comment Oct 1, 2025 5:54pm

@claude
Copy link
Copy Markdown

claude bot commented Oct 1, 2025

Claude finished @NathanFlurry's task —— View job


Pull Request Review

Reviewing CORS conflict fix changes across 3 files...

Todo List

  • Read repository guidelines from CLAUDE.md
  • Analyze vitest.config.ts changes
  • Analyze router.ts changes
  • Analyze mod.ts changes
  • Provide comprehensive code review feedback

Code Review Summary

This PR fixes a CORS configuration conflict between the inspector and main application routes. The changes address proper CORS middleware ordering and configuration isolation.

File Analysis

examples/chat-room/vitest.config.ts

Change: Added server configuration with port 5173

  • Quality: Good - follows standard Vitest configuration patterns
  • Purpose: Prevents port conflicts during testing
  • No issues identified

⚠️ packages/rivetkit/src/manager/router.ts (Main Changes)

Key Changes: Reordered CORS middleware application to fix conflicts

Positive Aspects:

  • Correct Fix: Moving inspector routes before main CORS middleware prevents conflicts
  • Good Documentation: Comment at lines 148-149 clearly explains the reasoning
  • Isolation: Inspector routes now have their own CORS configuration scope
  • Backward Compatibility: No breaking changes to existing API

Areas of Concern:

  1. Code Duplication (Lines 112, 168):

    if (runConfig.cors) router.use("*", corsMiddleware(runConfig.cors));

    This pattern appears twice. Consider extracting to a helper function:

    const applyCorsIfConfigured = (router: OpenAPIHono, cors: any) => {
      if (cors) router.use("*", corsMiddleware(cors));
    };
  2. Type Safety (Line 156):

    new Hono<{ Variables: { inspector: any } }>()

    Using any type reduces type safety. Should define proper inspector type.

  3. Error Handling: No validation that runConfig.inspector.cors exists before use at line 157.

packages/rivetkit/src/registry/mod.ts

Change: Updated inspector enabled check from object to boolean

  • Quality: Good - simplifies boolean logic
  • Consistency: Aligns with updated configuration pattern
  • No issues identified

Security Assessment

  • No Security Issues: CORS changes are defensive and properly scoped
  • Inspector Security: Continues to use secureInspector() middleware

Performance Considerations

  • Minimal Impact: Changes only affect route initialization, not runtime performance
  • Efficient Routing: Proper route ordering prevents unnecessary middleware execution

Test Coverage Gaps

  • ⚠️ Missing Tests: No tests verify the CORS conflict resolution
  • ⚠️ Integration Testing: Should test inspector and main routes with different CORS configs

Recommendations

  1. Add Type Safety: Replace any types with proper interfaces
  2. Extract Helper: Create reusable CORS application function
  3. Add Tests: Include integration tests for CORS configuration scenarios
  4. Documentation: Add JSDoc comments explaining the CORS ordering requirement

Overall Assessment

✅ APPROVE - This is a solid fix that addresses the reported CORS conflict. The solution is correct and well-documented. While there are minor improvement opportunities around type safety and code organization, the core fix is sound and ready for merge.

Copy link
Copy Markdown
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Oct 1, 2025

More templates

@rivetkit/actor

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/actor@1325

@rivetkit/cloudflare-workers

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/cloudflare-workers@1325

@rivetkit/core

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/core@1325

@rivetkit/db

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/db@1325

@rivetkit/framework-base

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/framework-base@1325

@rivetkit/next-js

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/next-js@1325

@rivetkit/react

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/react@1325

rivetkit

pnpm add https://pkg.pr.new/rivet-dev/rivetkit@1325

@rivetkit/sql-loader

pnpm add https://pkg.pr.new/rivet-dev/rivetkit/@rivetkit/sql-loader@1325

commit: ce68b82

@graphite-app
Copy link
Copy Markdown

graphite-app bot commented Oct 1, 2025

Merge activity

  • Oct 1, 5:55 PM UTC: NathanFlurry added this pull request to the Graphite merge queue.
  • Oct 1, 5:56 PM UTC: CI is running for this pull request on a draft pull request (#1327) due to your merge queue CI optimization settings.
  • Oct 1, 5:57 PM UTC: Merged by the Graphite merge queue via draft PR: #1327.

@graphite-app graphite-app bot closed this Oct 1, 2025
@graphite-app graphite-app bot deleted the 10-01-fix_core_fix_inspector_cors_conflicting_with_main_cors branch October 1, 2025 17:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant