This repository was archived by the owner on Feb 18, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ use crate::{
2222 progress:: Progress , progress_location:: ProgressLocation , progress_options:: ProgressOptions ,
2323 } ,
2424 context:: get_extension_context,
25- request:: make_request ,
25+ request:: make_request_with_legacy ,
2626} ;
2727
2828use self :: token:: Token ;
@@ -136,9 +136,10 @@ async fn polling(
136136 }
137137 _ => { }
138138 }
139- let mut response = make_request (
139+ let mut response = make_request_with_legacy (
140140 & format ! ( "/auth/poll?uuid={}&verifier={}" , uuid, verifier) ,
141141 HttpMethod :: Get ,
142+ true ,
142143 )
143144 . send ( )
144145 . await ?;
Original file line number Diff line number Diff line change @@ -3,14 +3,29 @@ pub mod stream;
33use node_bridge:: http_client:: { HttpMethod , HttpRequest } ;
44use serde:: Serialize ;
55
6- pub fn make_request ( path : & str , method : HttpMethod ) -> HttpRequest {
7- HttpRequest :: new ( & format ! ( "https://internal.cursor.sh{path}" ) )
6+ /// Make a request to the legacy host.
7+ ///
8+ /// Due to the higher version of Cursor modifying the API's host,
9+ /// but we found that the authentication interface has not been modified.
10+ ///
11+ /// We believe that Cursor will probably unify the host in the future, so this function is used for compatibility.
12+ pub fn make_request_with_legacy ( path : & str , method : HttpMethod , legacy_host : bool ) -> HttpRequest {
13+ let host = if legacy_host {
14+ "aicursor.com"
15+ } else {
16+ "internal.cursor.sh"
17+ } ;
18+ HttpRequest :: new ( & format ! ( "https://{host}{path}" ) )
819 . set_method ( method)
920 . add_header ( "accept" , "*/*" )
1021 . add_header ( "content-type" , "application/json" )
1122 . add_header ( "user-agent" , "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Cursor/0.2.7 Chrome/102.0.5005.167 Electron/19.1.9 Safari/537.36" )
1223}
1324
25+ pub fn make_request ( path : & str , method : HttpMethod ) -> HttpRequest {
26+ make_request_with_legacy ( path, method, false )
27+ }
28+
1429pub trait JsonSendable {
1530 fn set_json_body < T > ( self , body : & T ) -> Self
1631 where
Original file line number Diff line number Diff line change @@ -43,7 +43,11 @@ export class ExtensionContext implements IExtensionContext {
4343 progress . report ( { message } ) ;
4444 } ,
4545 } as IProgress ;
46- await callback ( wrappedProgress , abortController . signal ) ;
46+ try {
47+ await callback ( wrappedProgress , abortController . signal ) ;
48+ } catch ( e ) {
49+ console . error ( e ) ;
50+ }
4751 } ) ;
4852 }
4953
You can’t perform that action at this time.
0 commit comments