add cloudflare pages redirection
This commit is contained in:
17
functions/api/[[path]].ts
Normal file
17
functions/api/[[path]].ts
Normal file
@@ -0,0 +1,17 @@
|
||||
//this is purely for cloudflare pages redirection purposes
|
||||
|
||||
export async function onRequest(context: EventContext<unknown, string, unknown>) {
|
||||
// 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 })
|
||||
}
|
||||
Reference in New Issue
Block a user