28 lines
825 B
TypeScript
28 lines
825 B
TypeScript
|
'use server';
|
||
|
import axios from "axios";
|
||
|
|
||
|
const SIGNUP_URL = 'https://tachy.daoyoucloud.com/api/auth:signUp';
|
||
|
// const SIGNUP_URL = 'http://127.0.0.1:13000/api/auth:signUp';
|
||
|
|
||
|
|
||
|
export async function authenticate(_currentState: unknown, formData: FormData) {
|
||
|
return '';
|
||
|
}
|
||
|
|
||
|
export async function signup(_currentState: unknown, formData: FormData) {
|
||
|
const result = await fetch(SIGNUP_URL, {
|
||
|
method: 'POST',
|
||
|
headers: {
|
||
|
'X-App': 'danmu-sim',
|
||
|
"content-type": "application/json",
|
||
|
"x-authenticator": "basic",
|
||
|
"x-locale": "zh-CN",
|
||
|
"x-timezone": "+08:00",
|
||
|
},
|
||
|
body: JSON.stringify(Object.fromEntries(formData))
|
||
|
})
|
||
|
const response = await result.json();
|
||
|
if (response.errors) {
|
||
|
return response.errors[0].message;
|
||
|
}
|
||
|
}
|