jbilcke-hf HF staff commited on
Commit
0df1259
1 Parent(s): 9365f31

fix for UND_ERR_REQ_CONTENT_LENGTH_MISMATCH

Browse files
Files changed (1) hide show
  1. src/app/api/v1/export/route.ts +10 -14
src/app/api/v1/export/route.ts CHANGED
@@ -18,20 +18,16 @@ export async function POST(req: NextRequest, res: NextResponse) {
18
  }
19
  } catch (err) {}
20
 
21
- return NextResponse.redirect(`${
22
- process.env.AI_TUBE_CLAP_EXPORTER_URL || "http://localhost:7860"
23
- }?f=${format}`)
24
- }
25
- /*
26
- Alternative solution (in case the redirect doesn't work):
27
-
28
- We could also grab the blob and forward it, like this:
29
-
30
- const data = fetch(
31
- "https://jbilcke-hf-ai-tube-clap-exporter.hf.space",
32
  { method: "POST", body: await req.blob() }
33
  )
34
- const blob = data.blob()
35
 
36
- Then return the blob with the right Content-Type using NextResponse
37
- */
 
 
 
 
 
 
18
  }
19
  } catch (err) {}
20
 
21
+ // let's call our micro-service, which is currently open bar.
22
+ const result = await fetch(
23
+ `https://jbilcke-hf-ai-tube-clap-exporter.hf.space?f=${format}`,
 
 
 
 
 
 
 
 
24
  { method: "POST", body: await req.blob() }
25
  )
 
26
 
27
+ const blob = await result.blob()
28
+
29
+ return new NextResponse(blob, {
30
+ status: 200,
31
+ headers: new Headers({ "content-type": `video/${format}` }),
32
+ })
33
+ }