Skip to content

Commit ca1156a

Browse files
fix(base-url): use getBaseUrl helper in copilot revert state endpoint (#1706)
* revert base url * fix tests" ;
1 parent 89eb184 commit ca1156a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

apps/sim/app/api/copilot/checkpoints/revert/route.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ describe('Copilot Checkpoints Revert API Route', () => {
2323
setupCommonApiMocks()
2424
mockCryptoUuid()
2525

26+
// Mock getBaseUrl to return localhost for tests
27+
vi.doMock('@/lib/urls/utils', () => ({
28+
getBaseUrl: vi.fn(() => 'http://localhost:3000'),
29+
getBaseDomain: vi.fn(() => 'localhost:3000'),
30+
getEmailDomain: vi.fn(() => 'localhost:3000'),
31+
}))
32+
2633
mockSelect.mockReturnValue({ from: mockFrom })
2734
mockFrom.mockReturnValue({ where: mockWhere })
2835
mockWhere.mockReturnValue({ then: mockThen })

apps/sim/app/api/copilot/checkpoints/revert/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from '@/lib/copilot/auth'
1313
import { createLogger } from '@/lib/logs/console/logger'
1414
import { validateUUID } from '@/lib/security/input-validation'
15+
import { getBaseUrl } from '@/lib/urls/utils'
1516

1617
const logger = createLogger('CheckpointRevertAPI')
1718

@@ -93,7 +94,7 @@ export async function POST(request: NextRequest) {
9394
}
9495

9596
const stateResponse = await fetch(
96-
`${request.nextUrl.origin}/api/workflows/${checkpoint.workflowId}/state`,
97+
`${getBaseUrl()}/api/workflows/${checkpoint.workflowId}/state`,
9798
{
9899
method: 'PUT',
99100
headers: {

0 commit comments

Comments
 (0)