Skip to content

Commit

Permalink
chore: add index help
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Mar 22, 2023
1 parent 34616b2 commit 9cda9c5
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
/**
* Welcome to Cloudflare Workers! This is your first worker.
*
* - Run `wrangler dev src/index.ts` in your terminal to start a development server
* - Open a browser tab at http://localhost:8787/ to see your worker in action
* - Run `wrangler publish src/index.ts --name my-worker` to publish your worker
*
* Learn more at https://developers.cloudflare.com/workers/
*/

export interface Env {
// Example binding to KV. Learn more at https://developers.cloudflare.com/workers/runtime-apis/kv/
// MY_KV_NAMESPACE: KVNamespace;
Expand All @@ -28,7 +18,19 @@ export default {
_ctx: ExecutionContext
): Promise<Response> {
const url = new URL(request.url);
url.host = OPENAI_API_HOST;
return await fetch(url, request);

if (url.pathname === '/') {
return new Response(
'This is CloseAI (https://github.com/yjl9903/CloseAI)',
{
headers: {
'content-type': 'text/plain;charset=UTF-8',
},
}
);
} else {
url.host = OPENAI_API_HOST;
return await fetch(url, request);
}
},
};

0 comments on commit 9cda9c5

Please sign in to comment.