@@ -3,6 +3,7 @@ import prompts from "prompts";
33import { Account } from "@tago-io/sdk" ;
44import { OTPType } from "@tago-io/sdk/lib/types" ;
55
6+ import { addHttpsToUrl } from "../lib/add-https-to-url" ;
67import { errorHandler , highlightMSG , successMSG } from "../lib/messages" ;
78import { writeToken } from "../lib/token" ;
89
@@ -19,24 +20,34 @@ async function getTagoDeployURL(): Promise<{ urlAPI: string; urlSSE: string } |
1920 return ;
2021 }
2122
22- const { urlAPI } = await prompts ( { type : "text" , name : "urlAPI" , message : "Set the URL for the API service: " , hint : "https://api.tago.io" } ) ;
23+ let { urlAPI } = await prompts ( { type : "text" , name : "urlAPI" , message : "Set the URL for the API service: " , hint : "https://api.tago.io" } ) ;
2324 if ( ! urlAPI ) {
2425 return ;
2526 }
2627
28+ urlAPI = addHttpsToUrl ( urlAPI ) ;
29+
2730 const sanitizedUrlAPI = new URL ( urlAPI ) . origin ;
2831
2932 let { urlSSE } = await prompts ( { type : "text" , name : "urlSSE" , message : "Set the URL for the SSE service: " , hint : "https://sse.tago.io" } ) ;
33+
34+ urlSSE = addHttpsToUrl ( urlSSE ) ;
35+
3036 if ( ! urlSSE ) {
3137 urlSSE = sanitizedUrlAPI . replace ( "https://api." , "https://sse." ) ;
3238 }
3339
3440 if ( urlSSE ) {
41+ urlSSE = urlSSE . replace ( "api." , "sse." ) ;
42+
3543 const sseUrl = new URL ( urlSSE ) ;
3644 sseUrl . pathname = '/events' ;
3745 urlSSE = sseUrl . toString ( ) ;
3846 }
3947
48+ process . env . TAGOIO_API = sanitizedUrlAPI ;
49+ process . env . TAGOIO_SSE = urlSSE ;
50+
4051 return { urlAPI : sanitizedUrlAPI , urlSSE } ;
4152}
4253
0 commit comments