Spaces:
Paused
Paused
xiao commited on
Commit ·
27afa22
1
Parent(s): e65d32c
初始化
Browse files- app/api/wanjuan/route.ts +5 -8
app/api/wanjuan/route.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
| 1 |
-
|
| 2 |
-
import { auth } from "../auth";
|
| 3 |
-
|
| 4 |
-
export async function POST(req: NextRequest) {
|
| 5 |
-
const authResult = auth(req);
|
| 6 |
-
if (authResult.error) {
|
| 7 |
-
return authResult.msg;
|
| 8 |
-
}
|
| 9 |
try {
|
|
|
|
| 10 |
let body = { message: await req.json() };
|
| 11 |
|
| 12 |
console.log(JSON.stringify(body));
|
| 13 |
let res = "";
|
| 14 |
await fetch("http://47.94.237.159:8080/v1/wanjuan", {
|
| 15 |
method: "POST",
|
|
|
|
|
|
|
|
|
|
| 16 |
body: JSON.stringify(body),
|
| 17 |
})
|
| 18 |
.then((response) => response.json())
|
|
|
|
| 1 |
+
export async function POST(req: Request) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
try {
|
| 3 |
+
let token = process.env.WANJUAN_TOKEN;
|
| 4 |
let body = { message: await req.json() };
|
| 5 |
|
| 6 |
console.log(JSON.stringify(body));
|
| 7 |
let res = "";
|
| 8 |
await fetch("http://47.94.237.159:8080/v1/wanjuan", {
|
| 9 |
method: "POST",
|
| 10 |
+
headers: {
|
| 11 |
+
Authorization: "Bearer " + token,
|
| 12 |
+
},
|
| 13 |
body: JSON.stringify(body),
|
| 14 |
})
|
| 15 |
.then((response) => response.json())
|