snnsnn
snnsnn
CDCloudflare Developers
Created by snnsnn on 8/19/2024 in #pages-help
Do middlewares are counted as functions?
Ok, thanks.
9 replies
CDCloudflare Developers
Created by snnsnn on 8/19/2024 in #pages-help
Do middlewares are counted as functions?
I just realized I left out the most important detail. I was using functions/_middleware.js and that is the only middleware I use, so everything counts as function invocation, right?
9 replies
CDCloudflare Developers
Created by snnsnn on 8/19/2024 in #pages-help
Do middlewares are counted as functions?
I was using it as an easy way to detect static assets, I can remove it. So, without it, there should be no cost then. For example:
export async function onRequest(ctx) {
const { pathname } = new URL(ctx.request.url);

if (pathname.endsWith('.css')) {
return await ctx.env.ASSETS.fetch(ctx.request.url);
}

return new Response(HTML, {
headers: { 'Content-Type': 'text/html' },
});
}
export async function onRequest(ctx) {
const { pathname } = new URL(ctx.request.url);

if (pathname.endsWith('.css')) {
return await ctx.env.ASSETS.fetch(ctx.request.url);
}

return new Response(HTML, {
headers: { 'Content-Type': 'text/html' },
});
}
9 replies
CDCloudflare Developers
Created by snnsnn on 8/19/2024 in #pages-help
Do middlewares are counted as functions?
Without the middleware, I receive 404 for anything, including static assets.
9 replies
CDCloudflare Developers
Created by snnsnn on 8/19/2024 in #pages-help
Do middlewares are counted as functions?
I can not use a static index.html as I need to generate its content dynamically. I don't know how to serve it without a middleware.
9 replies