@@ -6,7 +6,7 @@ import { type NextRequest, NextResponse } from 'next/server'
66import { v4 as uuidv4 } from 'uuid'
77import { getSession } from '@/lib/auth'
88import { generateRequestId } from '@/lib/core/utils/request'
9- import { getBaseUrl } from '@/lib/core/utils/urls'
9+ import { getInternalApiBaseUrl } from '@/lib/core/utils/urls'
1010import {
1111 type RegenerateStateInput ,
1212 regenerateWorkflowStateIds ,
@@ -115,15 +115,18 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{
115115 // Step 3: Save the workflow state using the existing state endpoint (like imports do)
116116 // Ensure variables in state are remapped for the new workflow as well
117117 const workflowStateWithVariables = { ...workflowState , variables : remappedVariables }
118- const stateResponse = await fetch ( `${ getBaseUrl ( ) } /api/workflows/${ newWorkflowId } /state` , {
119- method : 'PUT' ,
120- headers : {
121- 'Content-Type' : 'application/json' ,
122- // Forward the session cookie for authentication
123- cookie : request . headers . get ( 'cookie' ) || '' ,
124- } ,
125- body : JSON . stringify ( workflowStateWithVariables ) ,
126- } )
118+ const stateResponse = await fetch (
119+ `${ getInternalApiBaseUrl ( ) } /api/workflows/${ newWorkflowId } /state` ,
120+ {
121+ method : 'PUT' ,
122+ headers : {
123+ 'Content-Type' : 'application/json' ,
124+ // Forward the session cookie for authentication
125+ cookie : request . headers . get ( 'cookie' ) || '' ,
126+ } ,
127+ body : JSON . stringify ( workflowStateWithVariables ) ,
128+ }
129+ )
127130
128131 if ( ! stateResponse . ok ) {
129132 logger . error ( `[${ requestId } ] Failed to save workflow state for template use` )
0 commit comments