File size: 1,133 Bytes
3444669
a874265
3444669
6fa5e4b
3444669
 
 
 
 
 
 
 
47eb5bf
 
 
 
 
 
3444669
47eb5bf
a874265
 
3444669
47eb5bf
3444669
47eb5bf
 
 
 
 
 
 
 
3444669
 
 
 
47eb5bf
3444669
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { NextRequest, NextResponse } from "next/server";
import { auth, getIP } from "../../auth";

export async function POST(req: NextRequest) {
  try {
    const authResult = auth(req);
    if (authResult.error) {
      return NextResponse.json(authResult, {
        status: 401,
      });
    }
    const token=req.headers.get("auth") ?? ""
    const name=req.nextUrl.searchParams.get("name")
    let body={
      nickName:name
    }
    let res=await fetch("https://eladmin.dwzynj.top/api/users/myCenter", {
        method: "PUT",
        headers:{
          "Content-Type":'application/json;charset=utf-8',
          "Authorization":token,
          "UserIp": String(getIP(req))
        },
        body:JSON.stringify(body)
      })
      if(res.status==401){
        let msg={
          flag:false,
          msg:"未登录!"
        }
      // console.log(res.status)
      return new Response(JSON.stringify(msg))
      }
    let msg=await res.json()
    // console.log(msg)
    return new Response(JSON.stringify(msg))
  } catch (e) {
    console.error("[eladmin] ", e);
    return new Response(JSON.stringify(e));
  }
}