william commited on
Commit
ef87a58
·
1 Parent(s): da106cc

test token

Browse files
src/app/page.tsx CHANGED
@@ -14,7 +14,6 @@ import {
14
  } from "@ant-design/icons";
15
  import { useEffect, useState } from "react";
16
  import StyleCard from "./style-card";
17
- import axios from "axios";
18
 
19
  const STYLEs = [
20
  {
 
14
  } from "@ant-design/icons";
15
  import { useEffect, useState } from "react";
16
  import StyleCard from "./style-card";
 
17
 
18
  const STYLEs = [
19
  {
src/app/style-transform/route.ts CHANGED
@@ -4,9 +4,12 @@ type Body = {
4
  pic: string;
5
  };
6
 
 
 
7
  export async function POST(req: Request) {
8
  const body = (await req.json()) as Body;
9
 
 
10
  const image = await axios
11
  .request({
12
  method: "post",
@@ -15,17 +18,14 @@ export async function POST(req: Request) {
15
  url: "https://sologenius-gen-ai.hf.space/style",
16
  headers: {
17
  "Content-Type": "application/json",
18
- Authorization: "Bearer kk",
19
  },
20
  data: JSON.stringify({
21
  style: body.style,
22
  pic: body.pic,
23
  }),
24
  })
25
- .then((response) => response.data.data)
26
- .catch((error) => {
27
- console.log(error);
28
- });
29
 
30
  return Response.json({
31
  message: "success",
 
4
  pic: string;
5
  };
6
 
7
+ const HF_TOKEN = process.env.api_token;
8
+
9
  export async function POST(req: Request) {
10
  const body = (await req.json()) as Body;
11
 
12
+ console.log("HF_TOKEN", HF_TOKEN);
13
  const image = await axios
14
  .request({
15
  method: "post",
 
18
  url: "https://sologenius-gen-ai.hf.space/style",
19
  headers: {
20
  "Content-Type": "application/json",
21
+ Authorization: `Bearer ${HF_TOKEN}`,
22
  },
23
  data: JSON.stringify({
24
  style: body.style,
25
  pic: body.pic,
26
  }),
27
  })
28
+ .then((response) => response.data.data);
 
 
 
29
 
30
  return Response.json({
31
  message: "success",