@@ -3,7 +3,7 @@ import {Context} from "hono";
33import { showErr } from "../shares/message" ;
44import * as configs from "../shares/configs" ;
55import * as refresh from "../shares/refresh" ;
6- import { encodeCallbackData , Secrets } from "../shares/secrets" ;
6+ import { encodeCallbackData , Secrets } from "../shares/secrets" ;
77
88const driver_map : string [ ] = [
99 "https://accounts.google.com/o/oauth2/v2/auth" ,
@@ -51,8 +51,9 @@ export async function oneLogin(c: Context) {
5151// 令牌申请 ##############################################################################
5252export async function oneToken ( c : Context ) {
5353 let login_data , client_uid , client_key , random_key , server_use ;
54- let driver_txt , params_all , random_uid ;
54+ let driver_txt , params_all , random_uid , server_url : string = driver_map [ 1 ] ;
5555 try { // 请求参数 ====================================================================
56+ if ( c . env . PROXY_API . length > 0 ) server_url = "https://" + c . env . PROXY_API + "/token" ;
5657 login_data = < string > c . req . query ( 'code' ) ;
5758 random_uid = < string > c . req . query ( 'state' ) ;
5859 server_use = local . getCookie ( c , 'server_use' )
@@ -87,7 +88,7 @@ export async function oneToken(c: Context) {
8788 // 执行请求 ===========================================================================
8889 try {
8990 const paramsString = new URLSearchParams ( params_all ) . toString ( ) ;
90- const response : Response = await fetch ( driver_map [ 1 ] , {
91+ const response : Response = await fetch ( server_url , {
9192 method : 'POST' , body : paramsString ,
9293 headers : { 'Content-Type' : 'application/x-www-form-urlencoded' , } ,
9394 } ) ;
@@ -139,5 +140,5 @@ export async function genToken(c: Context) {
139140 grant_type : 'refresh_token' ,
140141 refresh_token : refresh_text
141142 } ;
142- return await refresh . pubRenew ( c , driver_map [ 1 ] , params , "POST" , "access_token" , "copy" , "none" ) ;
143+ return await refresh . pubRenew ( c , driver_map [ 1 ] , params , "POST" , "access_token" , "copy" , "none" ) ;
143144}
0 commit comments