T1ckbase commited on
Commit
0abf878
·
1 Parent(s): f035308
Files changed (1) hide show
  1. main.ts +17 -1
main.ts CHANGED
@@ -168,7 +168,7 @@ app.post('/v1/images/generations', async (c) => {
168
  contentType: contentType,
169
  });
170
 
171
- const host = headers.get('Host') || c.req.header('Host');
172
  const url = `${host}/tmp/${fileId}`;
173
 
174
  console.log(`Generated image ${i + 1}/${numImages}: ${url}`);
@@ -215,5 +215,21 @@ app.post('/v1/images/generations', async (c) => {
215
  // return c.text('skibidi', 400);
216
  });
217
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  // Deno.serve({ port: 7860 }, app.fetch);
219
  export default app.fetch;
 
168
  contentType: contentType,
169
  });
170
 
171
+ const host = 'https://' + Deno.env.get('SPACE_HOST');
172
  const url = `${host}/tmp/${fileId}`;
173
 
174
  console.log(`Generated image ${i + 1}/${numImages}: ${url}`);
 
215
  // return c.text('skibidi', 400);
216
  });
217
 
218
+ app.post('*', async (c) => {
219
+ const headers = new Headers(c.req.raw.headers);
220
+ headers.delete('Authorization');
221
+ headers.has('x-use-cache') || headers.set('x-use-cache', 'false');
222
+ console.log('headers:', Object.fromEntries(headers));
223
+
224
+ const { pathname, search } = new URL(c.req.url);
225
+ const targetUrl = `${HF_API_URL}${pathname}${search}`;
226
+
227
+ return await fetch(targetUrl, {
228
+ method: 'POST',
229
+ headers: headers,
230
+ body: c.req.raw.body,
231
+ });
232
+ });
233
+
234
  // Deno.serve({ port: 7860 }, app.fetch);
235
  export default app.fetch;