mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-27 16:33:49 +00:00
google search docs
This commit is contained in:
@@ -52,7 +52,7 @@ export const jsonRes = <T = any>(
|
||||
} else if (openaiError[error?.response?.statusText]) {
|
||||
msg = openaiError[error.response.statusText];
|
||||
}
|
||||
console.log(error?.response);
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
res.status(code).json({
|
||||
@@ -92,7 +92,7 @@ export const sseErrRes = (res: NextApiResponse, error: any) => {
|
||||
} else if (openaiError[error?.response?.statusText]) {
|
||||
msg = openaiError[error.response.statusText];
|
||||
}
|
||||
console.log('sse error => ', error?.response);
|
||||
console.log('sse error => ', error);
|
||||
|
||||
sseResponse({
|
||||
res,
|
||||
|
@@ -1,37 +0,0 @@
|
||||
import axios from 'axios';
|
||||
import { Obj2Query } from '../tools';
|
||||
|
||||
export const getClientToken = (googleClientVerKey?: string) => {
|
||||
if (!googleClientVerKey || typeof window.grecaptcha === 'undefined' || !window.grecaptcha?.ready)
|
||||
return '';
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
window.grecaptcha.ready(async () => {
|
||||
try {
|
||||
const token = await window.grecaptcha.execute(googleClientVerKey, {
|
||||
action: 'submit'
|
||||
});
|
||||
resolve(token);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// service run
|
||||
export const authGoogleToken = async (data: {
|
||||
secret: string;
|
||||
response: string;
|
||||
remoteip?: string;
|
||||
}) => {
|
||||
const res = await axios.post<{
|
||||
score?: number;
|
||||
success: boolean;
|
||||
'error-codes': string[];
|
||||
}>(`https://www.recaptcha.net/recaptcha/api/siteverify?${Obj2Query(data)}`);
|
||||
|
||||
if (res.data.success) {
|
||||
return Promise.resolve('');
|
||||
}
|
||||
return Promise.reject(res?.data?.['error-codes']?.[0] || '非法环境');
|
||||
};
|
Reference in New Issue
Block a user