diff --git a/src/get_copilot_token.html b/src/get_copilot_token.html
new file mode 100644
index 0000000..e112820
--- /dev/null
+++ b/src/get_copilot_token.html
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+GitHub Copilot token Generator
+Loading...
+
+
Waiting login:
+
+Your token remains secure within your browser.
+You are welcome to press Ctrl+U to view the complete source code of the script.
+Or visit the following URL:
+
+
+
+
diff --git a/src/worker.mjs b/src/worker.mjs
index c1418a0..2cccd2f 100644
--- a/src/worker.mjs
+++ b/src/worker.mjs
@@ -1,3 +1,5 @@
+import token_html from "./get_copilot_token.html";
+
export default {
async fetch (request, env) {
if (request.method === "OPTIONS") {
@@ -7,6 +9,17 @@ export default {
if (url.pathname === "/v1/models") {
return handleModels(request);
}
+ if (url.pathname === "/token") {
+ return new Response(token_html, {
+ headers: { "Content-Type": "text/html" }
+ });
+ }
+ if (url.pathname === "/corsproxy" && url.search.startsWith("?https://")) {
+ let resp = await fetch(url.search.substring(1), request);
+ resp = new Response(resp.body, resp);
+ resp.headers.set("Access-Control-Allow-Origin", "*");
+ return resp;
+ }
const auth = request.headers.get("Authorization");
let authKey = auth && auth.split(" ")[1];
if (!authKey) {
diff --git a/wrangler.toml b/wrangler.toml
index 960a85f..c2d7580 100644
--- a/wrangler.toml
+++ b/wrangler.toml
@@ -1,7 +1,6 @@
name = "copilot"
main = "src/worker.mjs"
compatibility_date = "2024-01-17"
-no_bundle = true
[[kv_namespaces]]
binding = "KV"