bruhhh
This commit is contained in:
24
src/index.ts
24
src/index.ts
@@ -7,12 +7,24 @@
|
|||||||
*
|
*
|
||||||
* Bind resources to your worker in `wrangler.jsonc`. After adding bindings, a type definition for the
|
* Bind resources to your worker in `wrangler.jsonc`. After adding bindings, a type definition for the
|
||||||
* `Env` object can be regenerated with `npm run cf-typegen`.
|
* `Env` object can be regenerated with `npm run cf-typegen`.
|
||||||
*
|
*SEARCH_SAMESITE=CgQI6qAB; OTZ=8625314_72_76_104100_72_446760; SID=g.a000-ggXNGV_fs__oxZ_Y0rsnbZNg2KIAmZZawMX41zAcOllwPdL1g1hGryYKNKSIZDfTk1rdgACgYKAdUSARASFQHGX2Miptcb2FbxGqYc6NFvuCd08RoVAUF8yKraVaDzP8DpICS_20-Pk2yP0076; APISID=jAVdapGMQieVGfXn/Asu0F6TQGlJs5dUTR; SAPISID=OjyntSixLJqCFB2a/AjdtwvG7inwDcJ9xY; __Secure-1PAPISID=OjyntSixLJqCFB2a/AjdtwvG7inwDcJ9xY; __Secure-3PAPISID=OjyntSixLJqCFB2a/AjdtwvG7inwDcJ9xY; DV=0_mAIBaGqpGgQI8vDLYWcR-UCPCH6dkwKROTYdRKqAEAAHBZTN39JvlctgAAAOynmN2kUkUWMAAAAE5QmTO6HaWREAAAAEQfZKtuTRnEBAAAAGEHr9roHorh4SAAFGrvGChcmeSOOAgAPXPRbLTZouQnDgLA993eZD6zayaLgwAA; SIDCC=AKEyXzW3TN8hueyXdvaH_qhnT0rU72hAckJNCOZJzfdIS2dIP9esQwBMfmzsTGzkSvskhVgXcwQ
|
||||||
* Learn more at https://developers.cloudflare.com/workers/
|
* Learn more at https://developers.cloudflare.com/workers/
|
||||||
*/
|
*/
|
||||||
|
// import { ExecutionContext, Response, Request, Headers, URL, console, ExportedHandler, fetch } from '@cloudflare/workers-types';
|
||||||
|
import "@cloudflare/workers-types";
|
||||||
|
import type * as Types from '@cloudflare/workers-types/latest';
|
||||||
|
import * as cf from '@cloudflare/workers-types/latest';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
|
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
|
||||||
|
var cookie: Map<string, string> = new Map();
|
||||||
|
if (request.headers.has("Cookie")) {
|
||||||
|
var fuck = request.headers.get("Cookie")?.split(";");
|
||||||
|
for (const element of fuck) {
|
||||||
|
var t = element[0].trim().split("=")
|
||||||
|
cookie.set(t[0], t[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const targetUrl = 'https://related-digital.com';
|
const targetUrl = 'https://related-digital.com';
|
||||||
|
|
||||||
@@ -35,9 +47,15 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const response: Response = await fetch(proxyRequest);
|
||||||
|
|
||||||
const response = await fetch(proxyRequest);
|
const newResponse = new Response(response.body, response);
|
||||||
return response;
|
|
||||||
|
if (!cookie.has("visited")) {
|
||||||
|
newResponse.headers.set("Set-Cookie", "visited=true; Path=/");
|
||||||
|
}
|
||||||
|
|
||||||
|
return newResponse;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Proxy failed:', e);
|
console.error('Proxy failed:', e);
|
||||||
return new Response(`Failed to proxy request to ${targetUrl}`, { status: 502 });
|
return new Response(`Failed to proxy request to ${targetUrl}`, { status: 502 });
|
||||||
|
|||||||
Reference in New Issue
Block a user