fix(base-url): use getBaseUrl helper in copilot revert state endpoint (#1706)

* revert base url

* fix tests"
;
This commit is contained in:
Vikhyath Mondreti
2025-10-21 18:44:05 -07:00
committed by GitHub
parent 89eb1849d0
commit ca1156a6c2
2 changed files with 9 additions and 1 deletions

View File

@@ -23,6 +23,13 @@ describe('Copilot Checkpoints Revert API Route', () => {
setupCommonApiMocks()
mockCryptoUuid()
// Mock getBaseUrl to return localhost for tests
vi.doMock('@/lib/urls/utils', () => ({
getBaseUrl: vi.fn(() => 'http://localhost:3000'),
getBaseDomain: vi.fn(() => 'localhost:3000'),
getEmailDomain: vi.fn(() => 'localhost:3000'),
}))
mockSelect.mockReturnValue({ from: mockFrom })
mockFrom.mockReturnValue({ where: mockWhere })
mockWhere.mockReturnValue({ then: mockThen })

View File

@@ -12,6 +12,7 @@ import {
} from '@/lib/copilot/auth'
import { createLogger } from '@/lib/logs/console/logger'
import { validateUUID } from '@/lib/security/input-validation'
import { getBaseUrl } from '@/lib/urls/utils'
const logger = createLogger('CheckpointRevertAPI')
@@ -93,7 +94,7 @@ export async function POST(request: NextRequest) {
}
const stateResponse = await fetch(
`${request.nextUrl.origin}/api/workflows/${checkpoint.workflowId}/state`,
`${getBaseUrl()}/api/workflows/${checkpoint.workflowId}/state`,
{
method: 'PUT',
headers: {