From 286d094ea587896f1bbdde07eded83ebc5e8e622 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 24 May 2022 14:24:15 +0200 Subject: [PATCH] add cloudflare pages redirection --- functions/api/[[path]].ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 functions/api/[[path]].ts diff --git a/functions/api/[[path]].ts b/functions/api/[[path]].ts new file mode 100644 index 0000000000..4db4b1d4ea --- /dev/null +++ b/functions/api/[[path]].ts @@ -0,0 +1,17 @@ +//this is purely for cloudflare pages redirection purposes + +export async function onRequest(context: EventContext) { + // Contents of context object + const { + request, // same as existing Worker API + env, // same as existing Worker API + params, // if filename includes [id] or [[path]] + waitUntil, // same as ctx.waitUntil in existing Worker API + next, // used for middleware or to fetch assets + data, // arbitrary space for passing data between middlewares + } = context + + const url = new URL(request.url) + url.hostname = "app.windmill.dev" + return fetch(url.toString(), { method: request.method, body: request.body, headers: request.headers }) +}