Cloudflare pages access plugin for local

When running with wrangler dev for my functions, the cloudflareAccessPlugin stops the redirect back to the local wrangler server from working correctly. Is there a way to fix that redirect (it sends me back to https://127.0.0.1 eating the port and screwing up the protocol)? If not, what is the magical incantation to conditionally exclude that cloudflareAccessPlugin? The docs have something like this:
export const onRequest: PagesFunction<Env> = cloudflareAccessPlugin({
domain: "",
aud: "",
});
export const onRequest: PagesFunction<Env> = cloudflareAccessPlugin({
domain: "",
aud: "",
});
I tried turning it to something like this (and a few other variations), but it spits out the error about returning a response (no context.next?) when hitting the not local development pathway.
export const onRequest: PagesFunction<Env> = async (context) => {
if (context.env.ENVIRONMENT === "development") {
return await context.next();
} else {
return await cloudflareAccessPlugin(context.request, {
domain: "",
aud: "",
}, );
}
}
export const onRequest: PagesFunction<Env> = async (context) => {
if (context.env.ENVIRONMENT === "development") {
return await context.next();
} else {
return await cloudflareAccessPlugin(context.request, {
domain: "",
aud: "",
}, );
}
}
Disclaimer: I don't speak javascript or typescript well
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server